$body = 'comment body with skip comment approval';
$edit['subject[0][value]'
] =
$title;
$edit['comment_body[0][value]'
] =
$body;
$this->
drupalGet($this->node->
toUrl());
$this->
submitForm($edit, 'Preview'
);
// Cannot use assertRaw here since both title and body are in the form.
$preview =
(string) $this->
cssSelect('[data-drupal-selector="edit-comment-preview"]'
)[0
]->
getHtml();
$this->
assertStringContainsString($title,
$preview, 'Anonymous user can preview comment title.'
);
$this->
assertStringContainsString($body,
$preview, 'Anonymous user can preview comment body.'
);
// Preview comments (without `skip comment approval` permission).
user_role_revoke_permissions(RoleInterface::ANONYMOUS_ID,
['skip comment approval'
]);
$edit =
[];
$title = 'comment title without skip comment approval';
$body = 'comment body without skip comment approval';
$edit['subject[0][value]'
] =
$title;
$edit['comment_body[0][value]'
] =
$body;
$this->
drupalGet($this->node->
toUrl());
$this->
submitForm($edit, 'Preview'
);
// Cannot use assertRaw here since both title and body are in the form.
$preview =
(string) $this->
cssSelect('[data-drupal-selector="edit-comment-preview"]'
)[0
]->
getHtml();
$this->
assertStringContainsString($title,
$preview, 'Anonymous user can preview comment title.'
);
$this->
assertStringContainsString($body,
$preview, 'Anonymous user can preview comment body.'
);