function ResourceTestBase::getExpectedUnauthorizedAccessCacheability

Same name in this branch
  1. 10 core/modules/rest/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\rest\Functional\ResourceTestBase::getExpectedUnauthorizedAccessCacheability()
Same name in other branches
  1. 9 core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::getExpectedUnauthorizedAccessCacheability()
  2. 9 core/modules/rest/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\rest\Functional\ResourceTestBase::getExpectedUnauthorizedAccessCacheability()
  3. 8.9.x core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::getExpectedUnauthorizedAccessCacheability()
  4. 8.9.x core/modules/rest/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\rest\Functional\ResourceTestBase::getExpectedUnauthorizedAccessCacheability()
  5. 11.x core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::getExpectedUnauthorizedAccessCacheability()
  6. 11.x core/modules/rest/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\rest\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.
8 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 484

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.query_args',
        'url.site',
        'user.permissions',
    ])
        ->addCacheContexts($this->entity
        ->getEntityType()
        ->isRevisionable() ? [
        'url.query_args:resourceVersion',
    ] : []);
}

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