function CommentHelperCase::commentExists

Checks current page for specified comment.

Parameters

object $comment Comment object.:

boolean $reply The comment is a reply to another comment.:

Return value

boolean Comment found.

8 calls to CommentHelperCase::commentExists()
CommentAnonymous::testAnonymous in drupal/modules/comment/comment.test
Test anonymous comment functionality.
CommentApprovalTest::testApprovalAdminInterface in drupal/modules/comment/comment.test
Test comment approval functionality through admin/content/comment.
CommentApprovalTest::testApprovalNodeInterface in drupal/modules/comment/comment.test
Test comment approval functionality through node interface.
CommentContentRebuild::testCommentRebuild in drupal/modules/comment/comment.test
Test to ensure that the comment's content array is rebuilt for every call to comment_view().
CommentInterfaceTest::testCommentInterface in drupal/modules/comment/comment.test
Test comment interface.

... See full list

File

drupal/modules/comment/comment.test, line 107
Tests for comment.module.

Class

CommentHelperCase
@file Tests for comment.module.

Code

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

    // Comment anchor.
    $regex .= '<div(.*?)';

    // Begin in comment div.
    $regex .= $comment->subject . '(.*?)';

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

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