Created
November 7, 2014 14:21
-
-
Save danpoltawski/2944358981a323df35a1 to your computer and use it in GitHub Desktop.
hack formslib xpath alternative
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/composer.json b/composer.json | |
| index b6f5246..e74cb76 100644 | |
| --- a/composer.json | |
| +++ b/composer.json | |
| @@ -6,7 +6,7 @@ | |
| } | |
| ], | |
| "require-dev": { | |
| - "phpunit/phpunit": "3.7.*", | |
| + "phpunit/phpunit": "4.3.*", | |
| "phpunit/dbUnit": "1.2.*", | |
| "moodlehq/behat-extension": "1.28.4" | |
| } | |
| diff --git a/lib/tests/formslib_test.php b/lib/tests/formslib_test.php | |
| index 18e5edc..903c5ac 100644 | |
| --- a/lib/tests/formslib_test.php | |
| +++ b/lib/tests/formslib_test.php | |
| @@ -253,29 +253,31 @@ class core_formslib_testcase extends advanced_testcase { | |
| $form->display(); | |
| $html = ob_get_clean(); | |
| - $this->assertTag(array('tag'=>'select', 'id'=>'id_choose_one', | |
| - 'attributes'=>array('name'=>'choose_one')), $html); | |
| + $xml = new SimpleXMLElement($html); | |
| - $this->assertTag(array('tag'=>'input', 'id'=>'id_text_0', | |
| - 'attributes'=>array('type'=>'text', 'name'=>'text[0]')), $html); | |
| + $select = $xml->xpath("//select[@id='id_choose_one' and @name='choose_one']"); | |
| + $this->assertCount(1, $select); | |
| - $this->assertTag(array('tag'=>'input', 'id'=>'id_text_1', | |
| - 'attributes'=>array('type'=>'text', 'name'=>'text[1]')), $html); | |
| + $input0 = $xml->xpath("//input[@id='id_text_0' and @type='text' and @name='text[0]']"); | |
| + $this->assertCount(1, $input0); | |
| - $this->assertTag(array('tag'=>'input', 'id'=>'id_radio_choice_value', | |
| - 'attributes'=>array('type'=>'radio', 'name'=>'radio', 'value'=>'choice_value')), $html); | |
| + $input1 = $xml->xpath("//input[@id='id_text_1' and @type='text' and @name='text[1]']"); | |
| + $this->assertCount(1, $input1); | |
| - $this->assertTag(array('tag'=>'input', 'id'=>'customelementid2', | |
| - 'attributes'=>array('type'=>'radio', 'name'=>'radio2')), $html); | |
| + $radio0 = $xml->xpath("//input[@id='id_radio_choice_value' and @type='radio' and @name='radio' and @value='choice_value']"); | |
| + $this->assertCount(1, $radio0); | |
| - $this->assertTag(array('tag'=>'input', 'id'=>'id_repeatradio_0_2', | |
| - 'attributes'=>array('type'=>'radio', 'name'=>'repeatradio[0]', 'value'=>'2')), $html); | |
| + $radio1 = $xml->xpath("//input[@id='customelementid2' and @type='radio' and @name='radio2']"); | |
| + $this->assertCount(1, $radio1); | |
| - $this->assertTag(array('tag'=>'input', 'id'=>'id_repeatradio_2_1', | |
| - 'attributes'=>array('type'=>'radio', 'name'=>'repeatradio[2]', 'value'=>'1')), $html); | |
| + $repeatradio0 = $xml->xpath("//input[@id='id_repeatradio_0_2' and @type='radio' and @name='repeatradio[0]' and @value='2']"); | |
| + $this->assertCount(1, $repeatradio0); | |
| - $this->assertTag(array('tag'=>'input', 'id'=>'id_repeatradio_2_2', | |
| - 'attributes'=>array('type'=>'radio', 'name'=>'repeatradio[2]', 'value'=>'2')), $html); | |
| + $repeatradio1 = $xml->xpath("//input[@id='id_repeatradio_2_1' and @type='radio' and @name='repeatradio[2]' and @value='1']"); | |
| + $this->assertCount(1, $repeatradio1); | |
| + | |
| + $repeatradio2 = $xml->xpath("//input[@id='id_repeatradio_2_2' and @type='radio' and @name='repeatradio[2]' and @value='2']"); | |
| + $this->assertCount(1, $repeatradio2); | |
| } | |
| public function test_settype_debugging_text() { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment