function CommentThreadingTest::testCommentReplyLinkUnpublished

Same name and namespace in other branches
  1. 11.x core/modules/comment/tests/src/Functional/CommentThreadingTest.php \Drupal\Tests\comment\Functional\CommentThreadingTest::testCommentReplyLinkUnpublished()

Check the reply link on unpublished comments.

File

core/modules/comment/tests/src/Functional/CommentThreadingTest.php, line 24

Class

CommentThreadingTest
Tests to make sure the comment number increments properly.

Namespace

Drupal\Tests\comment\Functional

Code

public function testCommentReplyLinkUnpublished() : void {
  // Set comments to have a subject with preview disabled.
  $this->setCommentPreview(DRUPAL_DISABLED);
  $this->setCommentForm(FALSE);
  $this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_THREADED, 'Comment paging changed.');
  // Create a node.
  $this->drupalLogin($this->adminUser);
  $this->node = $this->drupalCreateNode([
    'type' => 'article',
    'promote' => 1,
    'uid' => $this->webUser
      ->id(),
  ]);
  // Post comment #1.
  $comment_text = $this->randomMachineName();
  $comment1 = $this->postComment($this->node, $comment_text, '', TRUE);
  $this->drupalGet($this->node
    ->toUrl());
  $this->assertSession()
    ->pageTextContains('Reply');
  $comment1->setUnpublished();
  $comment1->save();
  $this->drupalGet($this->node
    ->toUrl());
  $this->assertSession()
    ->pageTextNotContains('Reply');
}

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