// 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,
]);
$this->
drupalGet('node/' .
$this->node->
id());
// Verify that the comment field title is displayed.
$this->
assertSession()->
responseMatches('@<h2[^>]*>Comments</h2>@'
);
$this->
assertSession()->
linkExists('Log in', 1, 'Link to login was found.'
);
$this->
assertSession()->
linkExists('register', 1, 'Link to register was found.'
);
user_role_change_permissions(RoleInterface::ANONYMOUS_ID,
[ 'access comments' => FALSE,
'post comments' => TRUE,
'skip comment approval' => TRUE,
]);
$this->
drupalGet('node/' .
$this->node->
id());
// Verify that comments were not displayed.
$this->
assertSession()->
responseNotMatches('@<h2[^>]*>Comments</h2>@'
);