function CommentTestBase::commentExists

Checks current page for specified comment.

Parameters

Drupal\comment\Comment $comment: The comment object.

boolean $reply: Boolean indicating whether the comment is a reply to another comment.

Return value

boolean Boolean indicating whether the comment was found.

8 calls to CommentTestBase::commentExists()
CommentAnonymousTest::testAnonymous in drupal/core/modules/comment/lib/Drupal/comment/Tests/CommentAnonymousTest.php
Tests anonymous comment functionality.
CommentApprovalTest::testApprovalAdminInterface in drupal/core/modules/comment/lib/Drupal/comment/Tests/CommentApprovalTest.php
Test comment approval functionality through admin/content/comment.
CommentApprovalTest::testApprovalNodeInterface in drupal/core/modules/comment/lib/Drupal/comment/Tests/CommentApprovalTest.php
Tests comment approval functionality through the node interface.
CommentContentRebuildTest::testCommentRebuild in drupal/core/modules/comment/lib/Drupal/comment/Tests/CommentContentRebuildTest.php
Tests the rebuilding of comment's content arrays on calling comment_view().
CommentInterfaceTest::testCommentInterface in drupal/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php
Tests the comment interface.

... See full list

File

drupal/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php, line 166
Contains Drupal\comment\Tests\CommentTestBase.

Class

CommentTestBase
Provides setup and helper methods for comment tests.

Namespace

Drupal\comment\Tests

Code

function commentExists(Comment $comment = NULL, $reply = FALSE) {
  if ($comment) {
    $regex = '/' . ($reply ? '<div class="indented">(.*?)' : '');
    $regex .= '<a id="comment-' . $comment
      ->id() . '"(.*?)';

    // Comment anchor.
    $regex .= $comment->subject->value . '(.*?)';

    // Match subject.
    $regex .= $comment->comment_body->value . '(.*?)';

    // Match comment.
    $regex .= '/s';
    return (bool) preg_match($regex, $this
      ->drupalGetContent());
  }
  else {
    return FALSE;
  }
}