You are here

public function RenderCacheIntegrationTest::testBuildRenderableWithCacheContexts in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/Tests/RenderCacheIntegrationTest.php \Drupal\views\Tests\RenderCacheIntegrationTest::testBuildRenderableWithCacheContexts()

Ensure that the view renderable contains the cache contexts.

File

core/modules/views/src/Tests/RenderCacheIntegrationTest.php, line 287
Contains \Drupal\views\Tests\RenderCacheIntegrationTest.

Class

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

Namespace

Drupal\views\Tests

Code

public function testBuildRenderableWithCacheContexts() {
  $view = View::load('test_view');
  $display =& $view
    ->getDisplay('default');
  $display['cache_metadata']['contexts'] = [
    'views_test_cache_context',
  ];
  $executable = $view
    ->getExecutable();
  $build = $executable
    ->buildRenderable();
  $this
    ->assertEqual([
    'views_test_cache_context',
  ], $build['#cache']['contexts']);
}