diff --git a/core/modules/filter/tests/filter_test_plugin/src/Plugin/Filter/FilterSparkles.php b/core/modules/filter/tests/filter_test_plugin/src/Plugin/Filter/FilterSparkles.php index be2055b..f363fa9 100644 --- a/core/modules/filter/tests/filter_test_plugin/src/Plugin/Filter/FilterSparkles.php +++ b/core/modules/filter/tests/filter_test_plugin/src/Plugin/Filter/FilterSparkles.php @@ -11,7 +11,7 @@ * This filter does not do anything, but enabling of its module is done in a * test. * - * @see \Drupal\filter\Tests\FilterFormTest::testFilterForm() + * @see \Drupal\Tests\filter\Functional\FilterFormTest::testFilterForm() * * @Filter( * id = "filter_sparkles", diff --git a/core/modules/filter/src/Tests/FilterAdminTest.php b/core/modules/filter/tests/src/Functional/FilterAdminTest.php similarity index 96% rename from core/modules/filter/src/Tests/FilterAdminTest.php rename to core/modules/filter/tests/src/Functional/FilterAdminTest.php index aceeff5..3195a34 100644 --- a/core/modules/filter/src/Tests/FilterAdminTest.php +++ b/core/modules/filter/tests/src/Functional/FilterAdminTest.php @@ -1,13 +1,13 @@ xpath('//a[@href=:href]', [ ':href' => \Drupal::url('entity.filter_format.edit_form', ['filter_format' => $format_id]) ]); - $this->assertTrue($edit_link, format_string('Link href %href found.', + $this->assertNotEmpty($edit_link, format_string('Link href %href found.', ['%href' => 'admin/config/content/formats/manage/' . $format_id] )); $this->drupalGet('admin/config/content/formats/manage/' . $format_id); @@ -218,7 +218,7 @@ public function testFilterAdmin() { ':first' => 'filters[' . $first_filter . '][weight]', ':second' => 'filters[' . $second_filter . '][weight]', ]); - $this->assertTrue(!empty($elements), 'Order confirmed in admin interface.'); + $this->assertNotEmpty($elements, 'Order confirmed in admin interface.'); // Reorder filters. $edit = []; @@ -234,7 +234,7 @@ public function testFilterAdmin() { ':first' => 'filters[' . $second_filter . '][weight]', ':second' => 'filters[' . $first_filter . '][weight]', ]); - $this->assertTrue(!empty($elements), 'Reorder confirmed in admin interface.'); + $this->assertNotEmpty($elements, 'Reorder confirmed in admin interface.'); $filter_format = FilterFormat::load($restricted); foreach ($filter_format->filters() as $filter_name => $filter) { @@ -260,9 +260,9 @@ public function testFilterAdmin() { $format = FilterFormat::load($edit['format']); $this->assertNotNull($format, 'Format found in database.'); $this->drupalGet('admin/config/content/formats/manage/' . $format->id()); - $this->assertFieldByName('roles[' . RoleInterface::AUTHENTICATED_ID . ']', '', 'Role found.'); - $this->assertFieldByName('filters[' . $second_filter . '][status]', '', 'Line break filter found.'); - $this->assertFieldByName('filters[' . $first_filter . '][status]', '', 'URL filter found.'); + $this->assertFieldByName('roles[' . RoleInterface::AUTHENTICATED_ID . ']', TRUE); + $this->assertFieldByName('filters[' . $second_filter . '][status]', TRUE); + $this->assertFieldByName('filters[' . $first_filter . '][status]', TRUE); // Disable new filter. $this->drupalPostForm('admin/config/content/formats/manage/' . $format->id() . '/disable', [], t('Disable')); @@ -297,8 +297,8 @@ public function testFilterAdmin() { $this->assertText(t('Basic page @title has been created.', ['@title' => $edit['title[0][value]']]), 'Filtered node created.'); // Verify that the creation message contains a link to a node. - $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', [':href' => 'node/']); - $this->assert(isset($view_link), 'The message area contains a link to a node'); + $view_link = $this->xpath('//div[contains(@class, "messages")]//a[contains(@href, :href)]', [':href' => 'node/']); + $this->assertNotEmpty($view_link, 'The message area contains a link to a node'); $node = $this->drupalGetNodeByTitle($edit['title[0][value]']); $this->assertTrue($node, 'Node found in database.'); diff --git a/core/modules/filter/src/Tests/FilterFormTest.php b/core/modules/filter/tests/src/Functional/FilterFormTest.php similarity index 88% rename from core/modules/filter/src/Tests/FilterFormTest.php rename to core/modules/filter/tests/src/Functional/FilterFormTest.php index 9d0641e..fb0046b 100644 --- a/core/modules/filter/src/Tests/FilterFormTest.php +++ b/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 @@ protected function assertNoSelect($id) { */ 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 @@ protected function assertOptions($id, array $expected_options, $selected) { '@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 @@ protected function assertRequiredSelectAndOptions($id, array $options) { $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 @@ protected function assertEnabledTextarea($id) { $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 @@ protected function assertDisabledTextarea($id) { $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); } } diff --git a/core/modules/filter/src/Tests/FilterFormatAccessTest.php b/core/modules/filter/tests/src/Functional/FilterFormatAccessTest.php similarity index 98% rename from core/modules/filter/src/Tests/FilterFormatAccessTest.php rename to core/modules/filter/tests/src/Functional/FilterFormatAccessTest.php index a4c23b2..8c3394b 100644 --- a/core/modules/filter/src/Tests/FilterFormatAccessTest.php +++ b/core/modules/filter/tests/src/Functional/FilterFormatAccessTest.php @@ -1,11 +1,11 @@ getValue()] = $element; } $this->assertTrue(isset($options[$this->allowedFormat->id()]), 'The allowed text format appears as an option when adding a new node.'); $this->assertFalse(isset($options[$this->disallowedFormat->id()]), 'The disallowed text format does not appear as an option when adding a new node.'); diff --git a/core/modules/filter/src/Tests/FilterHtmlImageSecureTest.php b/core/modules/filter/tests/src/Functional/FilterHtmlImageSecureTest.php similarity index 88% rename from core/modules/filter/src/Tests/FilterHtmlImageSecureTest.php rename to core/modules/filter/tests/src/Functional/FilterHtmlImageSecureTest.php index 249021a..065d4a6 100644 --- a/core/modules/filter/src/Tests/FilterHtmlImageSecureTest.php +++ b/core/modules/filter/tests/src/Functional/FilterHtmlImageSecureTest.php @@ -1,20 +1,22 @@ drupalGetTestFiles('image'); + $test_images = $this->getTestFiles('image'); $test_image = $test_images[0]->filename; // Put a test image in the files directory with special filename. @@ -141,14 +143,14 @@ public function testImageSource() { foreach ($this->xpath('//img[@testattribute="' . hash('sha256', $image) . '"]') as $element) { $found = TRUE; if ($converted == $red_x_image) { - $this->assertEqual((string) $element['src'], $red_x_image); - $this->assertEqual((string) $element['alt'], $alt_text); - $this->assertEqual((string) $element['title'], $title_text); - $this->assertEqual((string) $element['height'], '16'); - $this->assertEqual((string) $element['width'], '16'); + $this->assertEqual($element->getAttribute('src'), $red_x_image); + $this->assertEqual($element->getAttribute('alt'), $alt_text); + $this->assertEqual($element->getAttribute('title'), $title_text); + $this->assertEqual($element->getAttribute('height'), '16'); + $this->assertEqual($element->getAttribute('width'), '16'); } else { - $this->assertEqual((string) $element['src'], $converted); + $this->assertEqual($element->getAttribute('src'), $converted); } } $this->assertTrue($found, format_string('@image was found.', ['@image' => $image]));