You are here

protected function ResourceTestBase::getExpectedCacheContexts in Drupal 9

Same name and namespace in other branches
  1. 8 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()

9 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.
CommentTest::getExpectedCacheContexts in core/modules/jsonapi/tests/src/Functional/CommentTest.php
The expected cache contexts for the GET/HEAD response of the test entity.
NodeTest::testGetIndividual in core/modules/jsonapi/tests/src/Functional/NodeTest.php
Tests GETting an individual resource, plus edge cases to ensure good DX.
ResourceTestBase::doTestIncluded in core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php
Tests included resources.
ResourceTestBase::doTestSparseFieldSets in core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php
Tests sparse field sets.

... See full list

8 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 518

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',
  ] : []);
}