You are here

public function RenderCacheIntegrationTest::testViewAddCacheMetadata in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/views/tests/src/Kernel/RenderCacheIntegrationTest.php \Drupal\Tests\views\Kernel\RenderCacheIntegrationTest::testViewAddCacheMetadata()
  2. 10 core/modules/views/tests/src/Kernel/RenderCacheIntegrationTest.php \Drupal\Tests\views\Kernel\RenderCacheIntegrationTest::testViewAddCacheMetadata()

Ensures that saving a view calculates the cache contexts.

File

core/modules/views/tests/src/Kernel/RenderCacheIntegrationTest.php, line 284

Class

RenderCacheIntegrationTest
Tests the general integration between views and the render cache.

Namespace

Drupal\Tests\views\Kernel

Code

public function testViewAddCacheMetadata() {
  $view = View::load('test_display');
  $view
    ->save();
  $this
    ->assertEqual([
    'languages:' . LanguageInterface::TYPE_CONTENT,
    'languages:' . LanguageInterface::TYPE_INTERFACE,
    'url.query_args',
    'user.node_grants:view',
    'user.permissions',
  ], $view
    ->getDisplay('default')['cache_metadata']['contexts']);
}