You are here

public function NodeListBuilderTest::testCacheContexts in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/node/tests/src/Kernel/NodeListBuilderTest.php \Drupal\Tests\node\Kernel\NodeListBuilderTest::testCacheContexts()

Tests that the correct cache contexts are set.

File

core/modules/node/tests/src/Kernel/NodeListBuilderTest.php, line 29

Class

NodeListBuilderTest
Tests the admin listing fallback when views is not enabled.

Namespace

Drupal\Tests\node\Kernel

Code

public function testCacheContexts() {

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