function CommentApproveLinkTest::testCommentApproveLink

Same name and namespace in other branches
  1. 9 core/modules/comment/tests/src/Functional/Views/CommentApproveLinkTest.php \Drupal\Tests\comment\Functional\Views\CommentApproveLinkTest::testCommentApproveLink()
  2. 11.x core/modules/comment/tests/src/Functional/Views/CommentApproveLinkTest.php \Drupal\Tests\comment\Functional\Views\CommentApproveLinkTest::testCommentApproveLink()

Tests that "approve comment" link exists and works as expected.

File

core/modules/comment/tests/src/Functional/Views/CommentApproveLinkTest.php, line 46

Class

CommentApproveLinkTest
Test the "approve_comment" views field for approving comments.

Namespace

Drupal\Tests\comment\Functional\Views

Code

public function testCommentApproveLink() : void {
  $this->drupalLogin($this->drupalCreateUser([
    'administer comments',
  ]));
  // Set the comment status to unpublished.
  $this->comment
    ->setUnpublished();
  $this->comment
    ->save();
  $this->drupalGet('/admin/moderate-comments');
  $this->assertSession()
    ->pageTextContains($this->comment
    ->getSubject());
  $this->assertSession()
    ->linkExists('Approve');
  $this->clickLink('Approve');
  $this->drupalGet('/admin/moderate-comments');
  $this->assertSession()
    ->linkNotExists('Approve');
  // Ensure that "published" column in table is marked as yes.
  $this->assertSession()
    ->elementTextContains('xpath', "//table/tbody/tr/td[3]", 'Yes');
}

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