protected function CommentThreadingTest::assertParentLink

Asserts that the link to the specified parent comment is present.

@parm int $cid The comment ID to check.

Parameters

int $pid: The expected parent comment ID.

1 call to CommentThreadingTest::assertParentLink()
CommentThreadingTest::testCommentThreading in drupal/core/modules/comment/lib/Drupal/comment/Tests/CommentThreadingTest.php
Tests the comment threading.

File

drupal/core/modules/comment/lib/Drupal/comment/Tests/CommentThreadingTest.php, line 130
Definition of Drupal\comment\Tests\CommentThreadingTest.

Class

CommentThreadingTest
Tests comment threading.

Namespace

Drupal\comment\Tests

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 = "//a[@id='comment-{$cid}']/following-sibling::article//p[contains(@class, 'parent')]//a[contains(@href, 'comment-{$pid}')]";
  $this
    ->assertFieldByXpath($pattern, NULL, format_string('Comment %cid has a link to parent %pid.', array(
    '%cid' => $cid,
    '%pid' => $pid,
  )));
}