function CommentNonNodeTest::getUnapprovedComment

Same name in other branches
  1. 9 core/modules/comment/tests/src/Functional/CommentNonNodeTest.php \Drupal\Tests\comment\Functional\CommentNonNodeTest::getUnapprovedComment()
  2. 8.9.x core/modules/comment/tests/src/Functional/CommentNonNodeTest.php \Drupal\Tests\comment\Functional\CommentNonNodeTest::getUnapprovedComment()
  3. 11.x core/modules/comment/tests/src/Functional/CommentNonNodeTest.php \Drupal\Tests\comment\Functional\CommentNonNodeTest::getUnapprovedComment()

Gets the comment ID for an unapproved comment.

Parameters

string $subject: Comment subject to find.

Return value

int Comment ID.

File

core/modules/comment/tests/src/Functional/CommentNonNodeTest.php, line 261

Class

CommentNonNodeTest
Tests commenting on a test entity.

Namespace

Drupal\Tests\comment\Functional

Code

public function getUnapprovedComment($subject) {
    $this->drupalGet('admin/content/comment/approval');
    preg_match('/href="(.*?)#comment-([^"]+)"(.*?)>(' . $subject . ')/', $this->getSession()
        ->getPage()
        ->getContent(), $match);
    return $match[2];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.