You are here

public function EntityListBuilderTest::testCacheContexts in Drupal 8

Same name and namespace in other branches
  1. 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 64

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
    ->assertEqual([
    'entity_test_view_grants',
    'languages:' . LanguageInterface::TYPE_INTERFACE,
    'theme',
    'url.query_args.pagers:0',
    'user.permissions',
  ], $build['#cache']['contexts']);
}