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