.../Tests/Core/Render/RendererBubblingTest.php | 5 ++- .../Core/Render/RendererPostRenderCacheTest.php | 40 +++++++++++++++++----- .../Drupal/Tests/Core/Render/RendererTest.php | 5 ++- 3 files changed, 40 insertions(+), 10 deletions(-) diff --git a/core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php b/core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php index 34c988c..b3fb803 100644 --- a/core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php +++ b/core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php @@ -34,6 +34,9 @@ public function testBubblingWithoutPreRender() { $this->elementInfo->expects($this->any()) ->method('getInfo') ->willReturn([]); + $this->cacheContexts->expects($this->any()) + ->method('convertTokensToKeys') + ->willReturnArgument(0); // Create an element with a child and subchild. Each element loads a // different library using #attached. @@ -94,7 +97,7 @@ public function testBubblingWithPrerender($test_element) { // - … is not cached DOES get called. \Drupal::state()->set('bubbling_nested_pre_render_cached', FALSE); \Drupal::state()->set('bubbling_nested_pre_render_uncached', FALSE); - $this->memoryCache->set('cached_nested', ['#markup' => 'Cached nested!', '#attached' => [], '#cache' => ['tags' => []], '#post_render_cache' => []]); + $this->memoryCache->set('cached_nested', ['#markup' => 'Cached nested!', '#attached' => [], '#cache' => ['contexts' => [], 'tags' => []], '#post_render_cache' => []]); // Simulate the rendering of an entire response (i.e. a root call). $output = $this->renderer->renderRoot($test_element); diff --git a/core/tests/Drupal/Tests/Core/Render/RendererPostRenderCacheTest.php b/core/tests/Drupal/Tests/Core/Render/RendererPostRenderCacheTest.php index cb7ccc3..46a49be 100644 --- a/core/tests/Drupal/Tests/Core/Render/RendererPostRenderCacheTest.php +++ b/core/tests/Drupal/Tests/Core/Render/RendererPostRenderCacheTest.php @@ -89,7 +89,10 @@ public function testPostRenderCacheWithColdCache() { '#markup' => '
#cache enabled, GET
', '#attached' => $test_element['#attached'], '#post_render_cache' => $test_element['#post_render_cache'], - '#cache' => ['tags' => ['rendered']], + '#cache' => [ + 'contexts' => [], + 'tags' => ['rendered'], + ], ]; $this->assertSame($cached_element, $expected_element, 'The correct data is cached: the stored #markup and #attached properties are not affected by #post_render_cache callbacks.'); @@ -222,7 +225,10 @@ public function testRenderChildrenPostRenderCacheDifferentContexts() { $context_3, ] ], - '#cache' => ['tags' => ['rendered']], + '#cache' => [ + 'contexts' => [], + 'tags' => ['rendered'], + ], ]; $dom = Html::load($cached_element['#markup']); @@ -314,7 +320,10 @@ public function testRenderChildrenPostRenderCacheComplex() { $context_3, ] ], - '#cache' => ['tags' => ['rendered']], + '#cache' => [ + 'contexts' => [], + 'tags' => ['rendered'], + ], ]; $dom = Html::load($cached_parent_element['#markup']); @@ -337,7 +346,10 @@ public function testRenderChildrenPostRenderCacheComplex() { $context_3, ] ], - '#cache' => ['tags' => ['rendered']], + '#cache' => [ + 'contexts' => [], + 'tags' => ['rendered'], + ], ]; $dom = Html::load($cached_child_element['#markup']); @@ -448,7 +460,10 @@ public function testPlaceholder() { $context ], ], - '#cache' => ['tags' => ['rendered']], + '#cache' => [ + 'contexts' => [], + 'tags' => ['rendered'], + ], ]; $this->assertSame($cached_element, $expected_element, 'The correct data is cached: the stored #markup and #attached properties are not affected by #post_render_cache callbacks.'); @@ -543,7 +558,10 @@ public function testChildElementPlaceholder() { $context, ], ], - '#cache' => ['tags' => ['rendered']], + '#cache' => [ + 'contexts' => [], + 'tags' => ['rendered'], + ], ]; $this->assertSame($cached_element, $expected_element, 'The correct data is cached for the child element: the stored #markup and #attached properties are not affected by #post_render_cache callbacks.'); @@ -568,7 +586,10 @@ public function testChildElementPlaceholder() { $context, ], ], - '#cache' => ['tags' => ['rendered']], + '#cache' => [ + 'contexts' => [], + 'tags' => ['rendered'], + ], ]; $this->assertSame($cached_element, $expected_element, 'The correct data is cached for the parent element: the stored #markup and #attached properties are not affected by #post_render_cache callbacks.'); @@ -596,7 +617,10 @@ public function testChildElementPlaceholder() { $context, ], ], - '#cache' => ['tags' => ['rendered']], + '#cache' => [ + 'contexts' => [], + 'tags' => ['rendered'], + ], ]; $this->assertSame($cached_element, $expected_element, 'The correct data is cached for the child element: the stored #markup and #attached properties are not affected by #post_render_cache callbacks.'); diff --git a/core/tests/Drupal/Tests/Core/Render/RendererTest.php b/core/tests/Drupal/Tests/Core/Render/RendererTest.php index 2f259b6..455834e 100644 --- a/core/tests/Drupal/Tests/Core/Render/RendererTest.php +++ b/core/tests/Drupal/Tests/Core/Render/RendererTest.php @@ -17,7 +17,10 @@ class RendererTest extends RendererTestBase { protected $defaultThemeVars = [ - '#cache' => ['tags' => []], + '#cache' => [ + 'contexts' => [], + 'tags' => [], + ], '#attached' => [], '#post_render_cache' => [], '#children' => '',