protected function CommentNotifyTestBase::commentExists in Comment Notify 8
Checks current page for specified comment.
Parameters
object $comment: Comment object.
bool $reply: The comment is a reply to another comment.
Return value
bool Comment found.
File
- tests/
src/ Functional/ CommentNotifyTestBase.php, line 134
Class
- CommentNotifyTestBase
- Comment notify Base Test class.
Namespace
Drupal\Tests\comment_notify\FunctionalCode
protected function commentExists($comment, $reply = FALSE) {
if ($comment && is_object($comment)) {
$regex = '/' . ($reply ? '<div class="indented">(.*?)' : '');
// Comment anchor.
$regex .= '<a id="comment-' . $comment->id . '"(.*?)';
// Begin in comment div.
$regex .= '<div(.*?)';
// Match subject.
$regex .= $comment->subject . '(.*?)';
// Match comment.
$regex .= $comment->comment . '(.*?)';
// Dot matches newlines and ensure that match doesn't bleed outside
// comment div.
$regex .= '<\\/div>/s';
return (bool) preg_match($regex, $this
->getSession()
->getPage()
->getContent());
}
else {
return FALSE;
}
}