You are here

protected function ResourceTestBase::getExpectedUnauthorizedAccessCacheability in Drupal 8

Same name in this branch
  1. 8 core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::getExpectedUnauthorizedAccessCacheability()
  2. 8 core/modules/rest/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\rest\Functional\ResourceTestBase::getExpectedUnauthorizedAccessCacheability()
Same name and namespace in other branches
  1. 9 core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::getExpectedUnauthorizedAccessCacheability()
  2. 10 core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::getExpectedUnauthorizedAccessCacheability()

Returns the expected cacheability for an unauthorized response.

Return value

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

3 calls to ResourceTestBase::getExpectedUnauthorizedAccessCacheability()
ResourceTestBase::testGetIndividual in core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php
Tests GETting an individual resource, plus edge cases to ensure good DX.
ResourceTestBase::testRevisions in core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php
Tests individual and collection revisions.
TermTest::getExpectedUnauthorizedAccessCacheability in core/modules/jsonapi/tests/src/Functional/TermTest.php
Returns the expected cacheability for an unauthorized response.
7 methods override ResourceTestBase::getExpectedUnauthorizedAccessCacheability()
BlockContentTest::getExpectedUnauthorizedAccessCacheability in core/modules/jsonapi/tests/src/Functional/BlockContentTest.php
Returns the expected cacheability for an unauthorized response.
BlockTest::getExpectedUnauthorizedAccessCacheability in core/modules/jsonapi/tests/src/Functional/BlockTest.php
Returns the expected cacheability for an unauthorized response.
CommentTest::getExpectedUnauthorizedAccessCacheability in core/modules/jsonapi/tests/src/Functional/CommentTest.php
Returns the expected cacheability for an unauthorized response.
FileUploadTest::getExpectedUnauthorizedAccessCacheability in core/modules/jsonapi/tests/src/Functional/FileUploadTest.php
Returns the expected cacheability for an unauthorized response.
MediaTest::getExpectedUnauthorizedAccessCacheability in core/modules/jsonapi/tests/src/Functional/MediaTest.php
Returns the expected cacheability for an unauthorized response.

... See full list

File

core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php, line 475

Class

ResourceTestBase
Subclass this for every JSON:API resource type.

Namespace

Drupal\Tests\jsonapi\Functional

Code

protected function getExpectedUnauthorizedAccessCacheability() {
  return (new CacheableMetadata())
    ->setCacheTags([
    '4xx-response',
    'http_response',
  ])
    ->setCacheContexts([
    'url.site',
    'user.permissions',
  ])
    ->addCacheContexts($this->entity
    ->getEntityType()
    ->isRevisionable() ? [
    'url.query_args:resourceVersion',
  ] : []);
}