X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Ffilter%2Ftests%2Fsrc%2FFunctional%2FFilterFormTest.php;fp=web%2Fcore%2Fmodules%2Ffilter%2Fsrc%2FTests%2FFilterFormTest.php;h=fb0046b08a30cb811106aea9370ea7f1b0661825;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hp=9d0641e41bd7ee018b311507f5febcc1ddb22ba7;hpb=aea91e65e895364e460983b890e295aa5d5540a5;p=yaffs-website diff --git a/web/core/modules/filter/src/Tests/FilterFormTest.php b/web/core/modules/filter/tests/src/Functional/FilterFormTest.php similarity index 88% rename from web/core/modules/filter/src/Tests/FilterFormTest.php rename to web/core/modules/filter/tests/src/Functional/FilterFormTest.php index 9d0641e41..fb0046b08 100644 --- a/web/core/modules/filter/src/Tests/FilterFormTest.php +++ b/web/core/modules/filter/tests/src/Functional/FilterFormTest.php @@ -1,17 +1,17 @@ xpath('//select[@id=:id]', [':id' => $id]); - return $this->assertFalse($select, SafeMarkup::format('Field @id does not exist.', [ + $this->assertEmpty($select, SafeMarkup::format('Field @id does not exist.', [ '@id' => $id, ])); } @@ -199,14 +196,13 @@ class FilterFormTest extends WebTestBase { */ protected function assertOptions($id, array $expected_options, $selected) { $select = $this->xpath('//select[@id=:id]', [':id' => $id]); - $select = reset($select); - $passed = $this->assertTrue($select instanceof \SimpleXMLElement, SafeMarkup::format('Field @id exists.', [ + $this->assertNotEmpty($select, SafeMarkup::format('Field @id exists.', [ '@id' => $id, ])); - - $found_options = $this->getAllOptions($select); + $select = reset($select); + $found_options = $select->findAll('css', 'option'); foreach ($found_options as $found_key => $found_option) { - $expected_key = array_search($found_option->attributes()->value, $expected_options); + $expected_key = array_search($found_option->getValue(), $expected_options); if ($expected_key !== FALSE) { $this->pass(SafeMarkup::format('Option @option for field @id exists.', [ '@option' => $expected_options[$expected_key], @@ -224,17 +220,15 @@ class FilterFormTest extends WebTestBase { '@option' => $expected_option, '@id' => $id, ])); - $passed = FALSE; } foreach ($found_options as $found_option) { $this->fail(SafeMarkup::format('Option @option for field @id does not exist.', [ - '@option' => $found_option->attributes()->value, + '@option' => $found_option->getValue(), '@id' => $id, ])); - $passed = FALSE; } - return $passed && $this->assertOptionSelected($id, $selected); + $this->assertOptionSelected($id, $selected); } /** @@ -253,14 +247,13 @@ class FilterFormTest extends WebTestBase { $select = $this->xpath('//select[@id=:id and contains(@required, "required")]', [ ':id' => $id, ]); - $select = reset($select); - $passed = $this->assertTrue($select instanceof \SimpleXMLElement, SafeMarkup::format('Required field @id exists.', [ + $this->assertNotEmpty($select, SafeMarkup::format('Required field @id exists.', [ '@id' => $id, ])); // A required select element has a "- Select -" option whose key is an empty // string. $options[] = ''; - return $passed && $this->assertOptions($id, $options, ''); + $this->assertOptions($id, $options, ''); } /** @@ -276,8 +269,7 @@ class FilterFormTest extends WebTestBase { $textarea = $this->xpath('//textarea[@id=:id and not(contains(@disabled, "disabled"))]', [ ':id' => $id, ]); - $textarea = reset($textarea); - return $this->assertTrue($textarea instanceof \SimpleXMLElement, SafeMarkup::format('Enabled field @id exists.', [ + $this->assertNotEmpty($textarea, SafeMarkup::format('Enabled field @id exists.', [ '@id' => $id, ])); } @@ -295,17 +287,17 @@ class FilterFormTest extends WebTestBase { $textarea = $this->xpath('//textarea[@id=:id and contains(@disabled, "disabled")]', [ ':id' => $id, ]); - $textarea = reset($textarea); - $passed = $this->assertTrue($textarea instanceof \SimpleXMLElement, SafeMarkup::format('Disabled field @id exists.', [ + $this->assertNotEmpty($textarea, SafeMarkup::format('Disabled field @id exists.', [ '@id' => $id, ])); + $textarea = reset($textarea); $expected = 'This field has been disabled because you do not have sufficient permissions to edit it.'; - $passed = $passed && $this->assertEqual((string) $textarea, $expected, SafeMarkup::format('Disabled textarea @id hides text in an inaccessible text format.', [ + $this->assertEqual($textarea->getText(), $expected, SafeMarkup::format('Disabled textarea @id hides text in an inaccessible text format.', [ '@id' => $id, ])); // Make sure the text format select is not shown. $select_id = str_replace('value', 'format--2', $id); - return $passed && $this->assertNoSelect($select_id); + $this->assertNoSelect($select_id); } }