function CommentAccessTest::testCannotCommentOnEntitiesYouCannotView
Same name in other branches
- 9 core/modules/comment/tests/src/Functional/CommentAccessTest.php \Drupal\Tests\comment\Functional\CommentAccessTest::testCannotCommentOnEntitiesYouCannotView()
- 8.9.x core/modules/comment/tests/src/Functional/CommentAccessTest.php \Drupal\Tests\comment\Functional\CommentAccessTest::testCannotCommentOnEntitiesYouCannotView()
- 11.x core/modules/comment/tests/src/Functional/CommentAccessTest.php \Drupal\Tests\comment\Functional\CommentAccessTest::testCannotCommentOnEntitiesYouCannotView()
Tests commenting disabled for access-blocked entities.
File
-
core/
modules/ comment/ tests/ src/ Functional/ CommentAccessTest.php, line 78
Class
- CommentAccessTest
- Tests comment administration and preview access.
Namespace
Drupal\Tests\comment\FunctionalCode
public function testCannotCommentOnEntitiesYouCannotView() : void {
$assert = $this->assertSession();
$comment_url = 'comment/reply/node/' . $this->unpublishedNode
->id() . '/comment';
// Commenting on an unpublished node results in access denied.
$this->drupalGet($comment_url);
$assert->statusCodeEquals(403);
// Publishing the node grants access.
$this->unpublishedNode
->setPublished()
->save();
$this->drupalGet($comment_url);
$assert->statusCodeEquals(200);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.