diff --git a/core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php b/core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php index 01e2061..34c988c 100644 --- a/core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php +++ b/core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php @@ -78,9 +78,8 @@ public function testBubblingWithPrerender($test_element) { \Drupal::getContainer()->set('state', $memory_state); $this->controllerResolver->expects($this->any()) ->method('getControllerFromDefinition') - ->willReturnCallback(function($callable) { - return $callable; - }); + ->willReturnArgument(0); + // Simulate the theme system/Twig: a recursive call to Renderer::render(), // just like the theme system or a Twig template would have done. $this->themeManager->expects($this->any()) @@ -149,7 +148,7 @@ class BubblingTest { * #pre_render callback for testBubblingWithPrerender(). */ public static function bubblingPreRender($elements) { - $callback = get_class() . '::bubblingPostRenderCache'; + $callback = __CLASS__ . '::bubblingPostRenderCache'; $context = [ 'foo' => 'bar', 'baz' => 'qux', @@ -178,11 +177,11 @@ public static function bubblingPreRender($elements) { ], 'child_nested_pre_render_uncached' => [ '#cache' => ['cid' => 'uncached_nested'], - '#pre_render' => [get_class() . '::bubblingNestedPreRenderUncached'], + '#pre_render' => [__CLASS__ . '::bubblingNestedPreRenderUncached'], ], 'child_nested_pre_render_cached' => [ '#cache' => ['cid' => 'cached_nested'], - '#pre_render' => [get_class() . '::bubblingNestedPreRenderCached'], + '#pre_render' => [__CLASS__ . '::bubblingNestedPreRenderCached'], ], ]; return $elements; @@ -209,7 +208,7 @@ public static function bubblingNestedPreRenderCached($elements) { * #post_render_cache callback for testBubblingWithPrerender(). */ public static function bubblingPostRenderCache(array $element, array $context) { - $callback = get_class() . '::bubblingPostRenderCache'; + $callback = __CLASS__ . '::bubblingPostRenderCache'; $placeholder = \Drupal::service('renderer')->generateCachePlaceholder($callback, $context); $element['#markup'] = str_replace($placeholder, 'Post-render cache!' . $context['foo'] . $context['baz'], $element['#markup']); return $element; diff --git a/core/tests/Drupal/Tests/Core/Render/RendererPostRenderCacheTest.php b/core/tests/Drupal/Tests/Core/Render/RendererPostRenderCacheTest.php index c6e1402..3fa4d7e 100644 --- a/core/tests/Drupal/Tests/Core/Render/RendererPostRenderCacheTest.php +++ b/core/tests/Drupal/Tests/Core/Render/RendererPostRenderCacheTest.php @@ -378,9 +378,9 @@ public function testRenderChildrenPostRenderCacheComplex() { * @covers ::doRender * @covers ::cacheGet * @covers ::processPostRenderCache - * @covers ::generateCachePlaceholder + * @covers ::generateCachePlaceholderV */ - function testPlaceholder() { + public function testPlaceholder() { $this->setupMemoryCache(); $context = [ @@ -466,7 +466,7 @@ function testPlaceholder() { * Tests child element that uses #post_render_cache but that is rendered via a * template. */ - function testChildElementPlaceholder() { + public function testChildElementPlaceholder() { $this->setupMemoryCache(); // Simulate the theme system/Twig: a recursive call to Renderer::render(), // just like the theme system or a Twig template would have done. @@ -657,7 +657,7 @@ protected function generatePostRenderCacheWithChildrenTestElement(array $context } /** - * @return \PHPUnit_Framework_MockObject_Builder_InvocationMocker + * @return \Drupal\Core\Theme\ThemeManagerInterface|\PHPUnit_Framework_MockObject_Builder_InvocationMocker */ protected function setupThemeManagerForDetails() { return $this->themeManager->expects($this->any()) diff --git a/core/tests/Drupal/Tests/Core/Render/RendererRecursionTest.php b/core/tests/Drupal/Tests/Core/Render/RendererRecursionTest.php index e9a4527..7b41128 100644 --- a/core/tests/Drupal/Tests/Core/Render/RendererRecursionTest.php +++ b/core/tests/Drupal/Tests/Core/Render/RendererRecursionTest.php @@ -15,7 +15,7 @@ */ class RendererRecursionTest extends RendererTestBase { - protected function setUpRenderPlainComplexElements() { + protected function setUpRenderRecursionComplexElements() { $complex_child_markup = '
Imagine this is a render array for an entity.
'; $parent_markup = 'Rendered!
'; @@ -45,11 +45,13 @@ protected function setUpRenderPlainComplexElements() { * ::renderRoot() may not be called inside of another ::renderRoot() call. * * @covers ::renderRoot + * @covers ::render + * @covers ::doRender * * @expectedException \LogicException */ - public function testRenderPlainWithNestedRenderRoot() { - list($complex_child_markup, $parent_markup, $complex_child_template) = $this->setUpRenderPlainComplexElements(); + public function testRenderRecursionWithNestedRenderRoot() { + list($complex_child_markup, $parent_markup, $complex_child_template) = $this->setUpRenderRecursionComplexElements(); $renderer = $this->renderer; $this->setUpRequest(); @@ -57,14 +59,6 @@ public function testRenderPlainWithNestedRenderRoot() { $callable = function () use ($renderer, $complex_child) { $renderer->renderRoot($complex_child); }; - $this->controllerResolver->expects($this->any()) - ->method('getControllerFromDefinition') - ->willReturnCallback(function($controller) use ($renderer, $callable) { - if ($controller == 'Drupal\Tests\Core\Render\PostRenderCache::callback') { - return [new PostRenderCache($renderer), 'callback']; - } - return $callable; - }); $page = [ 'content' => [ @@ -85,9 +79,10 @@ public function testRenderPlainWithNestedRenderRoot() { * * @covers ::renderRoot * @covers ::render + * @covers ::doRender */ - public function testRenderPlainWithNestedRender() { - list($complex_child_markup, $parent_markup, $complex_child_template) = $this->setUpRenderPlainComplexElements(); + public function testRenderRecursionWithNestedRender() { + list($complex_child_markup, $parent_markup, $complex_child_template) = $this->setUpRenderRecursionComplexElements(); $renderer = $this->renderer; $this->setUpRequest(); @@ -98,14 +93,6 @@ public function testRenderPlainWithNestedRender() { $this->assertEquals($complex_child_markup, $elements['#markup'], 'Rendered complex child output as expected, without the #post_render_cache callback executed.'); return $elements; }; - $this->controllerResolver->expects($this->any()) - ->method('getControllerFromDefinition') - ->willReturnCallback(function($controller) use ($renderer, $callable) { - if ($controller == 'Drupal\Tests\Core\Render\PostRenderCache::callback') { - return [new PostRenderCache($renderer), 'callback']; - } - return $callable; - }); $page = [ 'content' => [ @@ -130,8 +117,8 @@ public function testRenderPlainWithNestedRender() { * @covers ::renderRoot * @covers ::renderPlain */ - public function testRenderPlainWithNestedRenderPlain() { - list($complex_child_markup, $parent_markup, $complex_child_template) = $this->setUpRenderPlainComplexElements(); + public function testRenderRecursionWithNestedRenderPlain() { + list($complex_child_markup, $parent_markup, $complex_child_template) = $this->setUpRenderRecursionComplexElements(); $renderer = $this->renderer; $this->setUpRequest(); @@ -142,14 +129,6 @@ public function testRenderPlainWithNestedRenderPlain() { $this->assertEquals('overridden
', $elements['#markup'], 'Rendered complex child output as expected, with the #post_render_cache callback executed.'); return $elements; }; - $this->controllerResolver->expects($this->any()) - ->method('getControllerFromDefinition') - ->willReturnCallback(function($controller) use ($renderer, $callable) { - if ($controller == 'Drupal\Tests\Core\Render\PostRenderCache::callback') { - return [new PostRenderCache($renderer), 'callback']; - } - return $callable; - }); $page = [ 'content' => [