public function RendererBubblingTest::testOverWriteCacheKeys in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php \Drupal\Tests\Core\Render\RendererBubblingTest::testOverWriteCacheKeys()
- 10 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.
File
- core/
tests/ Drupal/ Tests/ Core/ Render/ RendererBubblingTest.php, line 617 - Contains \Drupal\Tests\Core\Render\RendererBubblingTest.
Class
- RendererBubblingTest
- @coversDefaultClass \Drupal\Core\Render\Renderer @group Render
Namespace
Drupal\Tests\Core\RenderCode
public function testOverWriteCacheKeys() {
$this
->setUpRequest();
$this
->setupMemoryCache();
// Ensure a logic exception
$data = [
'#cache' => [
'keys' => [
'llama',
'bar',
],
],
'#pre_render' => [
__NAMESPACE__ . '\\BubblingTest::bubblingCacheOverwritePrerender',
],
];
$this
->expectException(\LogicException::class);
$this
->expectExceptionMessage('Cache keys may not be changed after initial setup. Use the contexts property instead to bubble additional metadata.');
$this->renderer
->renderRoot($data);
}