function UserTest::getExpectedCacheContexts

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

Overrides ResourceTestBase::getExpectedCacheContexts

File

core/modules/jsonapi/tests/src/Functional/UserTest.php, line 175

Class

UserTest
JSON:API integration test for the "User" 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 || !empty(array_intersect([
        'mail',
        'display_name',
    ], $sparse_fieldset))) {
        $cache_contexts = Cache::mergeContexts($cache_contexts, [
            'user',
        ]);
    }
    return $cache_contexts;
}

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