You are here

protected function CommentThreadingTest::assertParentLink in Drupal 9

Same name and namespace in other branches
  1. 8 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()

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 135

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:
  // @code
  // <a id="comment-2"></a>
  // <article>
  //   <p class="parent">
  //     <a href="...comment-1"></a>
  //   </p>
  // </article>
  // @endcode
  $pattern = "//article[@id='comment-{$cid}']//p[contains(@class, 'parent')]//a[contains(@href, 'comment-{$pid}')]";
  $this
    ->assertSession()
    ->elementExists('xpath', $pattern);
}