$this->
drupalLogin($this->rootUser
);
$this->
drupalGet('admin/people/permissions'
);
$edit =
[ 'anonymous[access comments]' => 1,
'anonymous[post comments]' => 1,
'anonymous[skip comment approval]' => 0,
];
$this->
submitForm($edit, 'Save permissions'
);
$this->
drupalLogout();
// Ensure that the poster can leave some contact info.
$this->
setCommentAnonymous(CommentInterface::ANONYMOUS_MAY_CONTACT
);
// Post comment #2 as anonymous (comment approval enabled).
$this->
drupalGet('comment/reply/node/' .
$this->node->
id() . '/comment'
);
$anonymous_comment =
$this->
postComment($this->node,
$this->
randomMachineName(), '', TRUE
);
// Checks the new values of node comment statistics with comment #2 and
// ensure they haven't changed since the comment has not been moderated.
// The node needs to be reloaded with the cache reset.
$node_storage->
resetCache([$this->node->
id()]);
$node =
$node_storage->
load($this->node->
id());
$this->
assertSame('',
$node->
get('comment'
)->last_comment_name, 'The value of node last_comment_name should be an empty string.'
);