function ResourceTestBase::getExpectedCacheContexts

Same name and namespace in other branches
  1. 9 core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::getExpectedCacheContexts()
  2. 10 core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::getExpectedCacheContexts()
  3. 11.x core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::getExpectedCacheContexts()

The expected cache contexts for the GET/HEAD response of the test entity.

Parameters

array|null $sparse_fieldset: If a sparse fieldset is being requested, limit the expected cache contexts for this entity's fields to just these fields.

Return value

string[] A set of cache contexts.

See also

::testGetIndividual()

13 calls to ResourceTestBase::getExpectedCacheContexts()
BlockContentTest::getExpectedCacheContexts in core/modules/jsonapi/tests/src/Functional/BlockContentTest.php
The expected cache contexts for the GET/HEAD response of the test entity.
BlockTest::getExpectedCacheContexts in core/modules/jsonapi/tests/src/Functional/BlockTest.php
The expected cache contexts for the GET/HEAD response of the test entity.
CommentTest::getExpectedCacheContexts in core/modules/jsonapi/tests/src/Functional/CommentTest.php
The expected cache contexts for the GET/HEAD response of the test entity.
ConfigurableLanguageTest::getExpectedCacheContexts in core/modules/jsonapi/tests/src/Functional/ConfigurableLanguageTest.php
The expected cache contexts for the GET/HEAD response of the test entity.
ContentLanguageSettingsTest::getExpectedCacheContexts in core/modules/jsonapi/tests/src/Functional/ContentLanguageSettingsTest.php
The expected cache contexts for the GET/HEAD response of the test entity.

... See full list

7 methods override ResourceTestBase::getExpectedCacheContexts()
BlockContentTest::getExpectedCacheContexts in core/modules/jsonapi/tests/src/Functional/BlockContentTest.php
The expected cache contexts for the GET/HEAD response of the test entity.
BlockTest::getExpectedCacheContexts in core/modules/jsonapi/tests/src/Functional/BlockTest.php
The expected cache contexts for the GET/HEAD response of the test entity.
CommentTest::getExpectedCacheContexts in core/modules/jsonapi/tests/src/Functional/CommentTest.php
The expected cache contexts for the GET/HEAD response of the test entity.
ConfigurableLanguageTest::getExpectedCacheContexts in core/modules/jsonapi/tests/src/Functional/ConfigurableLanguageTest.php
The expected cache contexts for the GET/HEAD response of the test entity.
ContentLanguageSettingsTest::getExpectedCacheContexts in core/modules/jsonapi/tests/src/Functional/ContentLanguageSettingsTest.php
The expected cache contexts for the GET/HEAD response of the test entity.

... See full list

File

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

Class

ResourceTestBase
Subclass this for every JSON:API resource type.

Namespace

Drupal\Tests\jsonapi\Functional

Code

protected function getExpectedCacheContexts(array $sparse_fieldset = NULL) {
    $cache_contexts = [
        // Cache contexts for JSON:API URL query parameters.
'url.query_args:fields',
        'url.query_args:include',
        // Drupal defaults.
'url.site',
        'user.permissions',
    ];
    $entity_type = $this->entity
        ->getEntityType();
    return Cache::mergeContexts($cache_contexts, $entity_type->isRevisionable() ? [
        'url.query_args:resourceVersion',
    ] : []);
}

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