function EntityTestComputedFieldTest::getExpectedCacheContexts

Same name in other branches
  1. 9 core/modules/jsonapi/tests/src/Functional/EntityTestComputedFieldTest.php \Drupal\Tests\jsonapi\Functional\EntityTestComputedFieldTest::getExpectedCacheContexts()
  2. 10 core/modules/jsonapi/tests/src/Functional/EntityTestComputedFieldTest.php \Drupal\Tests\jsonapi\Functional\EntityTestComputedFieldTest::getExpectedCacheContexts()

Overrides ResourceTestBase::getExpectedCacheContexts

File

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

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',
        ]);
    }
    return $cache_contexts;
}

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