You are here

protected function EntityTestComputedFieldTest::getExpectedCacheContexts in Drupal 9

Same name and namespace in other branches
  1. 10 core/modules/jsonapi/tests/src/Functional/EntityTestComputedFieldTest.php \Drupal\Tests\jsonapi\Functional\EntityTestComputedFieldTest::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.

Overrides ResourceTestBase::getExpectedCacheContexts

See also

::testGetIndividual()

File

core/modules/jsonapi/tests/src/Functional/EntityTestComputedFieldTest.php, line 169

Class

EntityTestComputedFieldTest
JSON:API integration test for the "EntityTestComputedField" content entity type.

Namespace

Drupal\Tests\jsonapi\Functional

Code

protected function getExpectedCacheContexts(array $sparse_fieldset = NULL) {
  $cache_contexts = parent::getExpectedCacheContexts($sparse_fieldset);
  if ($sparse_fieldset === NULL || in_array('computed_test_cacheable_string_field', $sparse_fieldset)) {
    $cache_contexts = Cache::mergeContexts($cache_contexts, [
      'url.query_args:computed_test_cacheable_string_field',
    ]);
  }
  return $cache_contexts;
}