You are here

protected function EntityResourceTestBase::getExpectedUnauthorizedAccessCacheability in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::getExpectedUnauthorizedAccessCacheability()
  2. 10 core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::getExpectedUnauthorizedAccessCacheability()

Returns the expected cacheability of an unauthorized access response.

Return value

\Drupal\Core\Cache\RefinableCacheableDependencyInterface The expected cacheability.

Overrides ResourceTestBase::getExpectedUnauthorizedAccessCacheability

1 method overrides EntityResourceTestBase::getExpectedUnauthorizedAccessCacheability()
BlockResourceTestBase::getExpectedUnauthorizedAccessCacheability in core/modules/block/tests/src/Functional/Rest/BlockResourceTestBase.php
@todo Fix this in https://www.drupal.org/node/2820315.

File

core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php, line 352

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\EntityResource

Code

protected function getExpectedUnauthorizedAccessCacheability() {
  return (new CacheableMetadata())
    ->setCacheTags(static::$auth ? [
    '4xx-response',
    'http_response',
  ] : [
    '4xx-response',
    'config:user.role.anonymous',
    'http_response',
  ])
    ->setCacheContexts([
    'user.permissions',
  ]);
}