You are here

public function FlatCommentsReplyLinkTest::testCommentThreading in Flatcomments 8

Tests the comment reply link is hid correctly.

File

tests/src/Functional/FlatCommentsReplyLinkTest.php, line 41

Class

FlatCommentsReplyLinkTest
Test that the flat_comments module is hiding correctly the "reply" link.

Namespace

Drupal\Tests\flat_comments\Functional

Code

public function testCommentThreading() {

  // Set comments to have a subject with preview disabled.
  $field = FieldConfig::loadByName('node', 'article', 'comment');
  $field
    ->setSetting('default_mode', CommentManagerInterface::COMMENT_MODE_FLAT);
  $field
    ->setSetting('preview', DRUPAL_DISABLED);
  $field
    ->setSetting('form_location', TRUE);
  $field
    ->setThirdPartySetting('flat_comments', 'remove_reply_link', TRUE);
  $field
    ->save();

  // Create a node.
  $this
    ->drupalLogin($this->adminUser);
  $this->node = $this
    ->drupalCreateNode([
    'type' => 'article',
    'promote' => 1,
    'uid' => $this->adminUser
      ->id(),
  ]);

  // Post comment.
  $this
    ->drupalLogin($this->adminUser);
  $subject_text = $this
    ->randomMachineName();
  $comment_text = $this
    ->randomMachineName();
  $comment1 = $this
    ->postComment($this->node, $comment_text, $subject_text, TRUE);

  // Confirm that the comment was created.
  $this
    ->assertTrue($this
    ->commentExists($comment1), 'Comment found.');
  $this
    ->assertNoLink('Reply');
  $this
    ->drupalLogout();
}