You are here

protected static function BlockTest::getExpectedCollectionCacheability in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/jsonapi/tests/src/Functional/BlockTest.php \Drupal\Tests\jsonapi\Functional\BlockTest::getExpectedCollectionCacheability()

Computes the cacheability for a given entity collection.

Parameters

\Drupal\Core\Session\AccountInterface $account: An account for which cacheability should be computed (cacheability is dependent on access).

\Drupal\Core\Entity\EntityInterface[] $collection: The entities for which cacheability should be computed.

array $sparse_fieldset: (optional) If a sparse fieldset is being requested, limit the expected cacheability for the collection entities' fields to just those in the fieldset. NULL means all fields.

bool $filtered: Whether the collection is filtered or not.

Return value

\Drupal\Core\Cache\CacheableMetadata The expected cacheability for the given entity collection.

Overrides ResourceTestBase::getExpectedCollectionCacheability

File

core/modules/jsonapi/tests/src/Functional/BlockTest.php, line 189

Class

BlockTest
JSON:API integration test for the "Block" config entity type.

Namespace

Drupal\Tests\jsonapi\Functional

Code

protected static function getExpectedCollectionCacheability(AccountInterface $account, array $collection, array $sparse_fieldset = NULL, $filtered = FALSE) {
  return parent::getExpectedCollectionCacheability($account, $collection, $sparse_fieldset, $filtered)
    ->addCacheTags([
    'user:2',
  ])
    ->addCacheContexts([
    'user.roles',
  ]);
}