1 comment.test CommentHelperCase::commentExists($comment, $reply = FALSE)

Checks current page for specified comment.

Parameters

object $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.

File

core/modules/comment/tests/comment.test, line 159
Tests for the Comment module.

Class

CommentHelperCase

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 .= '<article(.*?)'; // Begin in comment wrapper.
    $regex .= $comment->subject . '(.*?)'; // Match subject.
    $regex .= $comment->comment . '(.*?)'; // Match comment.
    $regex .= '/s';

    return (boolean) preg_match($regex, $this->backdropGetContent());
  }
  else {
    return FALSE;
  }
}