function NodeListBuilderTest::testCacheContexts
Same name in other branches
- 9 core/modules/node/tests/src/Kernel/NodeListBuilderTest.php \Drupal\Tests\node\Kernel\NodeListBuilderTest::testCacheContexts()
- 8.9.x core/modules/node/tests/src/Kernel/NodeListBuilderTest.php \Drupal\Tests\node\Kernel\NodeListBuilderTest::testCacheContexts()
- 10 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 34
Class
- NodeListBuilderTest
- Tests the admin listing fallback when views is not enabled.
Namespace
Drupal\Tests\node\KernelCode
public function testCacheContexts() : void {
/** @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']);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.