public function CommentTest::testComments in Display Suite 8.2
Test adding comments to a node.
File
- src/
Tests/ CommentTest.php, line 81
Class
- CommentTest
- Tests for the manage display tab in Display Suite.
Namespace
Drupal\ds\TestsCode
public function testComments() {
// Create a node.
$settings = array(
'type' => 'article',
'promote' => 1,
);
$node = $this
->drupalCreateNode($settings);
$this
->dsSelectLayout(array(), array(), 'admin/structure/comment/manage/comment/display');
$fields = array(
'fields[comment_title][region]' => 'left',
'fields[comment_body][region]' => 'left',
);
$this
->dsConfigureUi($fields, 'admin/structure/comment/manage/comment/display');
// Post comment.
$comment1 = $this
->postComment($node, $this
->randomMachineName(), $this
->randomMachineName());
$this
->assertRaw($comment1->comment_body->value, 'Comment1 found.');
// Post comment.
$comment2 = $this
->postComment($node, $this
->randomMachineName(), $this
->randomMachineName());
$this
->assertRaw($comment2->comment_body->value, 'Comment2 found.');
// Verify there are no double ID's.
$xpath = $this
->xpath('//a[@id="comment-1"]');
$this
->assertEqual(count($xpath), 1, '1 ID found named comment-1');
// Test that hidden fields aren't exposed in the config.
$this
->dsSelectLayout();
$fields = array(
'fields[comment][region]' => 'hidden',
);
$this
->dsConfigureUi($fields);
$display = entity_get_display('node', 'article', 'default');
$content = $display
->get('content');
$hidden = $display
->get('hidden');
$this
->assertFalse(isset($content['comment']), 'Comment is not part of the content region');
$this
->assertTrue(isset($hidden['comment']), 'Comment is part of the hidden region');
}