You are here

public function RendererBubblingTest::testOverWriteCacheKeys in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php \Drupal\Tests\Core\Render\RendererBubblingTest::testOverWriteCacheKeys()

Tests that an element's cache keys cannot be changed during its rendering.

@expectedException \LogicException @expectedExceptionMessage Cache keys may not be changed after initial setup. Use the contexts property instead to bubble additional metadata.

File

core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php, line 578
Contains \Drupal\Tests\Core\Render\RendererBubblingTest.

Class

RendererBubblingTest
@coversDefaultClass \Drupal\Core\Render\Renderer @group Render

Namespace

Drupal\Tests\Core\Render

Code

public function testOverWriteCacheKeys() {
  $this
    ->setUpRequest();
  $this
    ->setupMemoryCache();

  // Ensure a logic exception
  $data = [
    '#cache' => [
      'keys' => [
        'llama',
        'bar',
      ],
    ],
    '#pre_render' => [
      __NAMESPACE__ . '\\BubblingTest::bubblingCacheOverwritePrerender',
    ],
  ];
  $this->renderer
    ->renderRoot($data);
}