You are here

protected function CommentThreadingTest::assertParentLink in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/comment/src/Tests/CommentThreadingTest.php \Drupal\comment\Tests\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/src/Tests/CommentThreadingTest.php
Tests the comment threading.

File

core/modules/comment/src/Tests/CommentThreadingTest.php, line 135
Contains \Drupal\comment\Tests\CommentThreadingTest.

Class

CommentThreadingTest
Tests to make sure the comment number increments properly.

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,
  )));
}