function RenderCacheIntegrationTest::testViewAddCacheMetadata

Same name in other branches
  1. 8.9.x 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()
  3. 11.x 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 288

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->assertEqualsCanonicalizing([
        'languages:' . LanguageInterface::TYPE_CONTENT,
        'languages:' . LanguageInterface::TYPE_INTERFACE,
        'url.query_args',
        'user.node_grants:view',
        'user.permissions',
    ], $view->getDisplay('default')['cache_metadata']['contexts']);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.