You are here

public function EntityListBuilderTest::testCacheContexts in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/tests/src/Functional/Entity/EntityListBuilderTest.php \Drupal\Tests\system\Functional\Entity\EntityListBuilderTest::testCacheContexts()
  2. 9 core/modules/system/tests/src/Functional/Entity/EntityListBuilderTest.php \Drupal\Tests\system\Functional\Entity\EntityListBuilderTest::testCacheContexts()

Tests that the correct cache contexts are set.

File

core/modules/system/tests/src/Functional/Entity/EntityListBuilderTest.php, line 63

Class

EntityListBuilderTest
Tests entity list builder functionality.

Namespace

Drupal\Tests\system\Functional\Entity

Code

public function testCacheContexts() {

  /** @var \Drupal\Core\Entity\EntityListBuilderInterface $list_builder */
  $list_builder = $this->container
    ->get('entity_type.manager')
    ->getListBuilder('entity_test');
  $build = $list_builder
    ->render();
  $this->container
    ->get('renderer')
    ->renderRoot($build);
  $this
    ->assertEqualsCanonicalizing([
    'entity_test_view_grants',
    'languages:' . LanguageInterface::TYPE_INTERFACE,
    'theme',
    'url.query_args.pagers:0',
    'user.permissions',
  ], $build['#cache']['contexts']);
}