public function CommentAccessTest::testCannotCommentOnEntitiesYouCannotView in Drupal 9
Same name and namespace in other branches
- 8 core/modules/comment/tests/src/Functional/CommentAccessTest.php \Drupal\Tests\comment\Functional\CommentAccessTest::testCannotCommentOnEntitiesYouCannotView()
- 10 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 76
Class
- CommentAccessTest
- Tests comment administration and preview access.
Namespace
Drupal\Tests\comment\FunctionalCode
public function testCannotCommentOnEntitiesYouCannotView() {
$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);
}