function CommentThreadingTest::assertParentLink

Same name in other branches
  1. 9 core/modules/comment/tests/src/Functional/CommentThreadingTest.php \Drupal\Tests\comment\Functional\CommentThreadingTest::assertParentLink()
  2. 10 core/modules/comment/tests/src/Functional/CommentThreadingTest.php \Drupal\Tests\comment\Functional\CommentThreadingTest::assertParentLink()
  3. 11.x 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.

Parameters

int $cid: The comment ID to check.

int $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 136

Class

CommentThreadingTest
Tests to make sure the comment number increments properly.

Namespace

Drupal\Tests\comment\Functional

Code

protected function assertParentLink($cid, $pid) {
    // This pattern matches a markup structure like:
    // <a id="comment-2"></a>
    // <article>
    //   <p class="parent">
    //     <a href="...comment-1"></a>
    //   </p>
    //  </article>
    $pattern = "//article[@id='comment-{$cid}']//p[contains(@class, 'parent')]//a[contains(@href, 'comment-{$pid}')]";
    $this->assertFieldByXpath($pattern, NULL, new FormattableMarkup('Comment %cid has a link to parent %pid.', [
        '%cid' => $cid,
        '%pid' => $pid,
    ]));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.