protected function CommentTest::getExpectedUnauthorizedAccessMessage in JSON:API 8
Same name and namespace in other branches
- 8.2 tests/src/Functional/CommentTest.php \Drupal\Tests\jsonapi\Functional\CommentTest::getExpectedUnauthorizedAccessMessage()
Return the expected error message.
Parameters
string $method: The HTTP method (GET, POST, PATCH, DELETE).
Return value
string The error string.
Overrides ResourceTestBase::getExpectedUnauthorizedAccessMessage
File
- tests/
src/ Functional/ CommentTest.php, line 290
Class
- CommentTest
- JSON API integration test for the "Comment" content entity type.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
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':
// @todo Make this unconditional when JSON API requires Drupal 8.6 or newer.
if (floatval(\Drupal::VERSION) >= 8.6) {
return "The 'edit own comments' permission is required, the user must be the comment author, and the comment must be published.";
}
default:
return parent::getExpectedUnauthorizedAccessMessage($method);
}
}