user_role_change_permissions(RoleInterface::ANONYMOUS_ID,
[ 'access comments' => FALSE,
'post comments' => FALSE,
'skip comment approval' => FALSE,
]);
// Attempt to view comments while disallowed.
// NOTE: if authenticated user has permission to post comments, then a
// "Login or register to post comments" type link may be shown.
$this->
drupalGet('node/' .
$this->node->
id());
// Verify that comments were not displayed.
$this->
assertSession()->
responseNotMatches('@<h2[^>]*>Comments</h2>@'
);
$this->
assertSession()->
linkNotExists('Add new comment', 'Link to add comment was found.'
);
// Attempt to view node-comment form while disallowed.
$this->
drupalGet('comment/reply/node/' .
$this->node->
id() . '/comment'
);
$this->
assertSession()->
statusCodeEquals(403
);
user_role_change_permissions(RoleInterface::ANONYMOUS_ID,
[ 'access comments' => TRUE,
'post comments' => FALSE,
'skip comment approval' => FALSE,
]);