You are here

function CommentModuleTestCase::comment_exists in SimpleTest 6

Checks current pag for specified comment.

Parameters

object $comment Comment object.:

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

Return value

boolean Comment found.

2 calls to CommentModuleTestCase::comment_exists()
CommentModuleTestCase::testAnonymous in tests/comment_module.test
Test anonymous comment functionality.
CommentModuleTestCase::testFormOnPage in tests/comment_module.test
Test comment form on node page.

File

tests/comment_module.test, line 245

Class

CommentModuleTestCase

Code

function comment_exists($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 .= '<\\/div>/s';

    // Dot matches newlines and ensure that match doesn't bleed outside comment div.
    return preg_match($regex, $this
      ->drupalGetContent());
  }
  else {
    return FALSE;
  }
}