diff --git a/core/modules/comment/src/Tests/CommentTestBase.php b/core/modules/comment/src/Tests/CommentTestBase.php index e15915f..7f9e3a2 100644 --- a/core/modules/comment/src/Tests/CommentTestBase.php +++ b/core/modules/comment/src/Tests/CommentTestBase.php @@ -2,6 +2,8 @@ namespace Drupal\comment\Tests; +@trigger_error('\Drupal\comment\Tests\CommentTestBase is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\comment\Functional\CommentTestBase', E_USER_DEPRECATED); + use Drupal\comment\Entity\CommentType; use Drupal\comment\Entity\Comment; use Drupal\comment\CommentInterface; @@ -12,6 +14,9 @@ /** * Provides setup and helper methods for comment tests. + * + * @deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. + * Use \Drupal\Tests\comment\Functional\CommentTestBase instead. */ abstract class CommentTestBase extends WebTestBase { diff --git a/core/modules/comment/src/Tests/Views/CommentTestBase.php b/core/modules/comment/src/Tests/Views/CommentTestBase.php index d7bec04..2b3ae1d 100644 --- a/core/modules/comment/src/Tests/Views/CommentTestBase.php +++ b/core/modules/comment/src/Tests/Views/CommentTestBase.php @@ -2,13 +2,17 @@ namespace Drupal\comment\Tests\Views; +@trigger_error('\Drupal\comment\Tests\Views\CommentTestBase is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\comment\Functional\Views\CommentTestBase', E_USER_DEPRECATED); + use Drupal\comment\Tests\CommentTestTrait; -use Drupal\views\Tests\ViewTestBase; use Drupal\views\Tests\ViewTestData; use Drupal\comment\Entity\Comment; /** * Tests the argument_comment_user_uid handler. + * + * @deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. + * Use \Drupal\Tests\comment\Functional\Views\CommentTestBase instead. */ abstract class CommentTestBase extends ViewTestBase { diff --git a/core/modules/comment/src/Tests/CommentActionsTest.php b/core/modules/comment/tests/src/Functional/CommentActionsTest.php similarity index 97% rename from core/modules/comment/src/Tests/CommentActionsTest.php rename to core/modules/comment/tests/src/Functional/CommentActionsTest.php index 56d34e4..79786fc 100644 --- a/core/modules/comment/src/Tests/CommentActionsTest.php +++ b/core/modules/comment/tests/src/Functional/CommentActionsTest.php @@ -1,6 +1,6 @@ drupalPostForm($this->node->urlInfo(), $edit, t('Preview')); // Cannot use assertRaw here since both title and body are in the form. - $preview = (string) $this->cssSelect('.preview')[0]->asXML(); + $preview = (string) $this->cssSelect('.preview')[0]->getHtml(); $this->assertTrue(strpos($preview, $title) !== FALSE, 'Anonymous user can preview comment title.'); $this->assertTrue(strpos($preview, $body) !== FALSE, 'Anonymous user can preview comment body.'); @@ -56,7 +56,7 @@ public function testAnonymous() { $edit['comment_body[0][value]'] = $body; $this->drupalPostForm($this->node->urlInfo(), $edit, t('Preview')); // Cannot use assertRaw here since both title and body are in the form. - $preview = (string) $this->cssSelect('.preview')[0]->asXML(); + $preview = (string) $this->cssSelect('.preview')[0]->getHtml(); $this->assertTrue(strpos($preview, $title) !== FALSE, 'Anonymous user can preview comment title.'); $this->assertTrue(strpos($preview, $body) !== FALSE, 'Anonymous user can preview comment body.'); user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['skip comment approval']); diff --git a/core/modules/comment/src/Tests/CommentBlockTest.php b/core/modules/comment/tests/src/Functional/CommentBlockTest.php similarity index 98% rename from core/modules/comment/src/Tests/CommentBlockTest.php rename to core/modules/comment/tests/src/Functional/CommentBlockTest.php index 37cc5de..db7d1bd 100644 --- a/core/modules/comment/src/Tests/CommentBlockTest.php +++ b/core/modules/comment/tests/src/Functional/CommentBlockTest.php @@ -1,6 +1,6 @@ drupalGet($this->node->urlInfo()); $element = $this->cssSelect('article.js-comment > div'); // Get last child element. - $element = end($element[0]); - $this->assertIdentical($element[0]->getName(), 'div', 'Last element is comment body.'); + $element = end($element); + $this->assertIdentical($element->getTagName(), 'div', 'Last element is comment body.'); // Change weight to make links go after comment body. entity_get_display('comment', 'comment', 'default') @@ -118,8 +118,8 @@ public function testCommentLinks() { $this->drupalGet($this->node->urlInfo()); $element = $this->cssSelect('article.js-comment > div'); // Get last child element. - $element = end($element[0]); - $this->assertIdentical($element[0]->getName(), 'ul', 'Last element is comment links.'); + $element = end($element); + $this->assertNotEmpty($element->find('css', 'ul.links'), 'Last element is comment links.'); // Make sure we can hide node links. entity_get_display('node', $this->node->bundle(), 'default') diff --git a/core/modules/comment/src/Tests/CommentNodeAccessTest.php b/core/modules/comment/tests/src/Functional/CommentNodeAccessTest.php similarity index 98% rename from core/modules/comment/src/Tests/CommentNodeAccessTest.php rename to core/modules/comment/tests/src/Functional/CommentNodeAccessTest.php index ffbffa1..6842dc1 100644 --- a/core/modules/comment/src/Tests/CommentNodeAccessTest.php +++ b/core/modules/comment/tests/src/Functional/CommentNodeAccessTest.php @@ -1,6 +1,6 @@ drupalGet('comment/reply/entity_test/' . $this->entity->id() . '/comment'); $xpath = '//nav[@class="breadcrumb"]/ol/li[last()]/a'; - $this->assertEqual(current($this->xpath($xpath)), $this->entity->label(), 'Last breadcrumb item is equal to node title on comment reply page.'); + $this->assertEqual(current($this->xpath($xpath))->getText(), $this->entity->label(), 'Last breadcrumb item is equal to node title on comment reply page.'); // Post a comment. /** @var \Drupal\comment\CommentInterface $comment1 */ @@ -283,17 +284,17 @@ public function testCommentFunctionality() { // Test breadcrumb on comment reply page. $this->drupalGet('comment/reply/entity_test/' . $this->entity->id() . '/comment/' . $comment1->id()); $xpath = '//nav[@class="breadcrumb"]/ol/li[last()]/a'; - $this->assertEqual(current($this->xpath($xpath)), $comment1->getSubject(), 'Last breadcrumb item is equal to comment title on comment reply page.'); + $this->assertEqual(current($this->xpath($xpath))->getText(), $comment1->getSubject(), 'Last breadcrumb item is equal to comment title on comment reply page.'); // Test breadcrumb on comment edit page. $this->drupalGet('comment/' . $comment1->id() . '/edit'); $xpath = '//nav[@class="breadcrumb"]/ol/li[last()]/a'; - $this->assertEqual(current($this->xpath($xpath)), $comment1->getSubject(), 'Last breadcrumb item is equal to comment subject on edit page.'); + $this->assertEqual(current($this->xpath($xpath))->getText(), $comment1->getSubject(), 'Last breadcrumb item is equal to comment subject on edit page.'); // Test breadcrumb on comment delete page. $this->drupalGet('comment/' . $comment1->id() . '/delete'); $xpath = '//nav[@class="breadcrumb"]/ol/li[last()]/a'; - $this->assertEqual(current($this->xpath($xpath)), $comment1->getSubject(), 'Last breadcrumb item is equal to comment subject on delete confirm page.'); + $this->assertEqual(current($this->xpath($xpath))->getText(), $comment1->getSubject(), 'Last breadcrumb item is equal to comment subject on delete confirm page.'); // Unpublish the comment. $this->performCommentOperation($comment1, 'unpublish'); diff --git a/core/modules/comment/src/Tests/CommentPreviewTest.php b/core/modules/comment/tests/src/Functional/CommentPreviewTest.php similarity index 92% rename from core/modules/comment/src/Tests/CommentPreviewTest.php rename to core/modules/comment/tests/src/Functional/CommentPreviewTest.php index 1b07fe6..89ac668 100644 --- a/core/modules/comment/src/Tests/CommentPreviewTest.php +++ b/core/modules/comment/tests/src/Functional/CommentPreviewTest.php @@ -1,11 +1,12 @@ assertFieldByName('comment_body[0][value]', $edit['comment_body[0][value]'], 'Comment field displayed.'); // Store the content of this page. - $content = $this->getRawContent(); $this->drupalPostForm(NULL, [], 'Save'); $this->assertText('Your comment has been posted.'); $elements = $this->xpath('//section[contains(@class, "comment-wrapper")]/article'); $this->assertEqual(1, count($elements)); - // Reset the content of the page to simulate the browser's back button, and - // re-submit the form. - $this->setRawContent($content); - $this->drupalPostForm(NULL, [], 'Save'); + // Go back and re-submit the form. + $this->getSession()->getDriver()->back(); $this->assertText('Your comment has been posted.'); $elements = $this->xpath('//section[contains(@class, "comment-wrapper")]/article'); $this->assertEqual(2, count($elements)); @@ -173,11 +175,11 @@ public function testCommentEditPreviewSave() { // Submit the form using the displayed values. $displayed = []; - $displayed['subject[0][value]'] = (string) current($this->xpath("//input[@id='edit-subject-0-value']/@value")); - $displayed['comment_body[0][value]'] = (string) current($this->xpath("//textarea[@id='edit-comment-body-0-value']")); - $displayed['uid'] = (string) current($this->xpath("//input[@id='edit-uid']/@value")); - $displayed['date[date]'] = (string) current($this->xpath("//input[@id='edit-date-date']/@value")); - $displayed['date[time]'] = (string) current($this->xpath("//input[@id='edit-date-time']/@value")); + $displayed['subject[0][value]'] = current($this->xpath("//input[@id='edit-subject-0-value']"))->getValue(); + $displayed['comment_body[0][value]'] = current($this->xpath("//textarea[@id='edit-comment-body-0-value']"))->getValue(); + $displayed['uid'] = current($this->xpath("//input[@id='edit-uid']"))->getValue(); + $displayed['date[date]'] = current($this->xpath("//input[@id='edit-date-date']"))->getValue(); + $displayed['date[time]'] = current($this->xpath("//input[@id='edit-date-time']"))->getValue(); $this->drupalPostForm('comment/' . $comment->id() . '/edit', $displayed, t('Save')); // Check that the saved comment is still correct. diff --git a/core/modules/comment/src/Tests/CommentRssTest.php b/core/modules/comment/tests/src/Functional/CommentRssTest.php similarity index 97% rename from core/modules/comment/src/Tests/CommentRssTest.php rename to core/modules/comment/tests/src/Functional/CommentRssTest.php index 35cad71..60708bd 100644 --- a/core/modules/comment/src/Tests/CommentRssTest.php +++ b/core/modules/comment/tests/src/Functional/CommentRssTest.php @@ -1,6 +1,6 @@ xpath('div/h3/a'); - if (empty($comment_title) || ((string)$comment_title[0]) !== $comment->getSubject()) { + $comment_title = $comment_element[0]->find('xpath', 'div/h3/a'); + if (empty($comment_title) || $comment_title->getText() !== $comment->getSubject()) { return FALSE; } - $comment_body = $comment_element[0]->xpath('div/div/p'); - if (empty($comment_body) || ((string)$comment_body[0]) !== $comment->comment_body->value) { + $comment_body = $comment_element[0]->find('xpath', 'div/div/p'); + if (empty($comment_body) || $comment_body->getText() !== $comment->comment_body->value) { return FALSE; } diff --git a/core/modules/comment/src/Tests/CommentThreadingTest.php b/core/modules/comment/tests/src/Functional/CommentThreadingTest.php similarity index 99% rename from core/modules/comment/src/Tests/CommentThreadingTest.php rename to core/modules/comment/tests/src/Functional/CommentThreadingTest.php index 8f412b2..cff22ba 100644 --- a/core/modules/comment/src/Tests/CommentThreadingTest.php +++ b/core/modules/comment/tests/src/Functional/CommentThreadingTest.php @@ -1,6 +1,6 @@ assertPattern('|