function CommentPagerTest::testCommentPermalink
Same name in other branches
- 9 core/modules/comment/tests/src/Functional/CommentPagerTest.php \Drupal\Tests\comment\Functional\CommentPagerTest::testCommentPermalink()
- 8.9.x core/modules/comment/tests/src/Functional/CommentPagerTest.php \Drupal\Tests\comment\Functional\CommentPagerTest::testCommentPermalink()
- 10 core/modules/comment/tests/src/Functional/CommentPagerTest.php \Drupal\Tests\comment\Functional\CommentPagerTest::testCommentPermalink()
Confirms comment paging works correctly with flat and threaded comments.
File
-
core/
modules/ comment/ tests/ src/ Functional/ CommentPagerTest.php, line 116
Class
- CommentPagerTest
- Tests paging of comments and their settings.
Namespace
Drupal\Tests\comment\FunctionalCode
public function testCommentPermalink() : void {
$this->drupalLogin($this->adminUser);
// Set comment variables.
$this->setCommentForm(TRUE);
$this->setCommentSubject(TRUE);
$this->setCommentPreview(DRUPAL_DISABLED);
// Create a node and three comments.
$node = $this->drupalCreateNode([
'type' => 'article',
'promote' => 1,
]);
$comments = [];
$comments[] = $this->postComment($node, 'comment 1: ' . $this->randomMachineName(), $this->randomMachineName(), TRUE);
$comments[] = $this->postComment($node, 'comment 2: ' . $this->randomMachineName(), $this->randomMachineName(), TRUE);
$comments[] = $this->postComment($node, 'comment 3: ' . $this->randomMachineName(), $this->randomMachineName(), TRUE);
$this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_FLAT, 'Comment paging changed.');
// Set comments to one per page so that we are able to test paging without
// needing to insert large numbers of comments.
$this->setCommentsPerPage(1);
// Navigate to each comment permalink as anonymous and assert it appears on
// the page.
foreach ($comments as $index => $comment) {
$this->drupalGet($comment->toUrl());
$this->assertTrue($this->commentExists($comment), sprintf('Comment %d appears on page %d.', $index + 1, $index + 1));
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.