$this->
drupalLogout();
// Post anonymous comment without contact info.
$subject =
$this->
randomMachineName();
$body =
$this->
randomMachineName();
// Set $contact to true so that it won't check for id and message.
$this->
postComment($this->node,
$body,
$subject, TRUE
);
$this->
assertSession()->
pageTextContains('Your comment has been queued for review by site administrators and will be published after approval.'
);
// Get unapproved comment id.
$this->
drupalLogin($this->adminUser
);
$anonymous_comment4 =
$this->
getUnapprovedComment($subject);
$anonymous_comment4 = Comment::
create([ 'cid' =>
$anonymous_comment4,
'subject' =>
$subject,
'comment_body' =>
$body,
'entity_id' =>
$this->node->
id(),
'entity_type' => 'node',
'field_name' => 'comment',
]);
$this->
drupalLogout();
$this->
assertFalse($this->
commentExists($anonymous_comment4), 'Anonymous comment was not published.'
);