function CommentThreadingTest::assertParentLink
Same name in other branches
- 9 core/modules/comment/tests/src/Functional/CommentThreadingTest.php \Drupal\Tests\comment\Functional\CommentThreadingTest::assertParentLink()
- 8.9.x core/modules/comment/tests/src/Functional/CommentThreadingTest.php \Drupal\Tests\comment\Functional\CommentThreadingTest::assertParentLink()
- 10 core/modules/comment/tests/src/Functional/CommentThreadingTest.php \Drupal\Tests\comment\Functional\CommentThreadingTest::assertParentLink()
Asserts that the link to the specified parent comment is present.
@internal
Parameters
string $cid: The comment ID to check.
string $pid: The expected parent comment ID.
1 call to CommentThreadingTest::assertParentLink()
- CommentThreadingTest::testCommentThreading in core/
modules/ comment/ tests/ src/ Functional/ CommentThreadingTest.php - Tests the comment threading.
File
-
core/
modules/ comment/ tests/ src/ Functional/ CommentThreadingTest.php, line 161
Class
- CommentThreadingTest
- Tests to make sure the comment number increments properly.
Namespace
Drupal\Tests\comment\FunctionalCode
protected function assertParentLink(string $cid, string $pid) : void {
// This pattern matches a markup structure like:
// @code
// <article id="comment-2">
// <p>
// In reply to
// <a href="...comment-1"></a>
// </p>
// </article>
// @endcode
$pattern = "//article[@id='comment-{$cid}']//p/a[contains(@href, 'comment-{$pid}')]";
$this->assertSession()
->elementExists('xpath', $pattern);
// A parent link is always accompanied by the text "In reply to".
// If we don't assert this text here, then the assertNoParentLink()
// method is not effective.
$pattern = "//article[@id='comment-{$cid}']";
$this->assertSession()
->elementTextContains('xpath', $pattern, 'In reply to');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.