function EntityResourceTestBase::getExpectedUnauthorizedAccessMessage
Same name in other branches
- 9 core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::getExpectedUnauthorizedAccessMessage()
- 10 core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::getExpectedUnauthorizedAccessMessage()
- 11.x core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::getExpectedUnauthorizedAccessMessage()
Overrides ResourceTestBase::getExpectedUnauthorizedAccessMessage
36 calls to EntityResourceTestBase::getExpectedUnauthorizedAccessMessage()
- BaseFieldOverrideResourceTestBase::getExpectedUnauthorizedAccessMessage in core/
tests/ Drupal/ FunctionalTests/ Rest/ BaseFieldOverrideResourceTestBase.php - Return the expected error message.
- BlockContentResourceTestBase::getExpectedUnauthorizedAccessMessage in core/
modules/ block_content/ tests/ src/ Functional/ Rest/ BlockContentResourceTestBase.php - Return the expected error message.
- BlockResourceTestBase::getExpectedUnauthorizedAccessMessage in core/
modules/ block/ tests/ src/ Functional/ Rest/ BlockResourceTestBase.php - Return the expected error message.
- CommentResourceTestBase::getExpectedUnauthorizedAccessMessage in core/
modules/ comment/ tests/ src/ Functional/ Rest/ CommentResourceTestBase.php - Return the expected error message.
- ConfigTestResourceTestBase::getExpectedUnauthorizedAccessMessage in core/
modules/ config/ tests/ config_test/ tests/ src/ Functional/ Rest/ ConfigTestResourceTestBase.php - Return the expected error message.
32 methods override EntityResourceTestBase::getExpectedUnauthorizedAccessMessage()
- BaseFieldOverrideResourceTestBase::getExpectedUnauthorizedAccessMessage in core/
tests/ Drupal/ FunctionalTests/ Rest/ BaseFieldOverrideResourceTestBase.php - Return the expected error message.
- BlockContentResourceTestBase::getExpectedUnauthorizedAccessMessage in core/
modules/ block_content/ tests/ src/ Functional/ Rest/ BlockContentResourceTestBase.php - Return the expected error message.
- BlockResourceTestBase::getExpectedUnauthorizedAccessMessage in core/
modules/ block/ tests/ src/ Functional/ Rest/ BlockResourceTestBase.php - Return the expected error message.
- CommentResourceTestBase::getExpectedUnauthorizedAccessMessage in core/
modules/ comment/ tests/ src/ Functional/ Rest/ CommentResourceTestBase.php - Return the expected error message.
- ConfigTestResourceTestBase::getExpectedUnauthorizedAccessMessage in core/
modules/ config/ tests/ config_test/ tests/ src/ Functional/ Rest/ ConfigTestResourceTestBase.php - Return the expected error message.
File
-
core/
modules/ rest/ tests/ src/ Functional/ EntityResource/ EntityResourceTestBase.php, line 344
Class
- EntityResourceTestBase
- Even though there is the generic EntityResource, it's necessary for every entity type to have its own test, because they each have different fields, validation constraints, et cetera. It's not because the generic case works, that every caseā¦
Namespace
Drupal\Tests\rest\Functional\EntityResourceCode
protected function getExpectedUnauthorizedAccessMessage($method) {
if ($this->config('rest.settings')
->get('bc_entity_resource_permissions')) {
return parent::getExpectedUnauthorizedAccessMessage($method);
}
$permission = $this->entity
->getEntityType()
->getAdminPermission();
if ($permission !== FALSE) {
return "The '{$permission}' permission is required.";
}
$http_method_to_entity_operation = [
'GET' => 'view',
'POST' => 'create',
'PATCH' => 'update',
'DELETE' => 'delete',
];
$operation = $http_method_to_entity_operation[$method];
$message = sprintf('You are not authorized to %s this %s entity', $operation, $this->entity
->getEntityTypeId());
if ($this->entity
->bundle() !== $this->entity
->getEntityTypeId()) {
$message .= ' of bundle ' . $this->entity
->bundle();
}
return "{$message}.";
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.