public function CommentTest::testCommentUser in Display Suite 8.2
Test User custom display on a comment on a node.
File
- src/
Tests/ CommentTest.php, line 125
Class
- CommentTest
- Tests for the manage display tab in Display Suite.
Namespace
Drupal\ds\TestsCode
public function testCommentUser() {
// Create a node.
$settings = array(
'type' => 'article',
'promote' => 1,
);
$node = $this
->drupalCreateNode($settings);
// User compact display settings.
$this
->dsSelectLayout(array(), array(), 'admin/config/people/accounts/display');
$fields = array(
'fields[username][region]' => 'left',
'fields[member_for][region]' => 'left',
);
$this
->dsConfigureUi($fields, 'admin/config/people/accounts/display');
// Comment display settings.
$this
->dsSelectLayout(array(), array(), 'admin/structure/comment/manage/comment/display');
$fields = array(
'fields[comment_title][region]' => 'left',
'fields[comment_user][region]' => 'left',
'fields[comment_body][region]' => 'left',
);
$this
->dsConfigureUi($fields, 'admin/structure/comment/manage/comment/display');
// Post comment.
$comment = $this
->postComment($node, $this
->randomMachineName(), $this
->randomMachineName());
$this
->assertRaw($comment->comment_body->value, 'Comment found.');
$this
->assertRaw('Member for', 'Comment Member for found.');
$xpath = $this
->xpath('//div[@class="field field--name-comment-user field--type-ds field--label-hidden field__item"]/div/div/div[@class="field field--name-username field--type-ds field--label-hidden field__item"]');
$this
->assertEqual(count($xpath), 1, 'Username');
}