function CommentResourceTestBase::getExpectedUnauthorizedAccessMessage

Same name in other branches
  1. 9 core/modules/comment/tests/src/Functional/Rest/CommentResourceTestBase.php \Drupal\Tests\comment\Functional\Rest\CommentResourceTestBase::getExpectedUnauthorizedAccessMessage()
  2. 8.9.x core/modules/comment/tests/src/Functional/Rest/CommentResourceTestBase.php \Drupal\Tests\comment\Functional\Rest\CommentResourceTestBase::getExpectedUnauthorizedAccessMessage()
  3. 10 core/modules/comment/tests/src/Functional/Rest/CommentResourceTestBase.php \Drupal\Tests\comment\Functional\Rest\CommentResourceTestBase::getExpectedUnauthorizedAccessMessage()

Overrides EntityResourceTestBase::getExpectedUnauthorizedAccessMessage

File

core/modules/comment/tests/src/Functional/Rest/CommentResourceTestBase.php, line 333

Class

CommentResourceTestBase

Namespace

Drupal\Tests\comment\Functional\Rest

Code

protected function getExpectedUnauthorizedAccessMessage($method) {
    switch ($method) {
        case 'GET':
            return "The 'access comments' permission is required and the comment must be published.";
        case 'POST':
            return "The 'post comments' permission is required.";
        case 'PATCH':
            return "The 'edit own comments' permission is required, the user must be the comment author, and the comment must be published.";
        case 'DELETE':
        default:
            // \Drupal\comment\CommentAccessControlHandler::checkAccess() does not
            // specify a reason for not allowing a comment to be deleted.
            return '';
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.