...nderPlainTest.php => RendererRecursionTest.php} | 39 +++++++++++++++------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/core/tests/Drupal/Tests/Core/Render/RendererRenderPlainTest.php b/core/tests/Drupal/Tests/Core/Render/RendererRecursionTest.php similarity index 84% rename from core/tests/Drupal/Tests/Core/Render/RendererRenderPlainTest.php rename to core/tests/Drupal/Tests/Core/Render/RendererRecursionTest.php index 8337b5e..e9a4527 100644 --- a/core/tests/Drupal/Tests/Core/Render/RendererRenderPlainTest.php +++ b/core/tests/Drupal/Tests/Core/Render/RendererRecursionTest.php @@ -2,7 +2,7 @@ /** * @file - * Contains \Drupal\Tests\Core\Render\RendererTest. + * Contains \Drupal\Tests\Core\Render\RendererRecursionTest. */ namespace Drupal\Tests\Core\Render; @@ -13,9 +13,9 @@ * @coversDefaultClass \Drupal\Core\Render\Renderer * @group Render */ -class RendererRenderPlainTest extends RendererTestBase { +class RendererRecursionTest extends RendererTestBase { - protected function setupRenderPlainComplexElements() { + protected function setUpRenderPlainComplexElements() { $complex_child_markup = '

Imagine this is a render array for an entity.

'; $parent_markup = '

Rendered!

'; @@ -42,15 +42,17 @@ protected function setupRenderPlainComplexElements() { } /** + * ::renderRoot() may not be called inside of another ::renderRoot() call. + * + * @covers ::renderRoot + * * @expectedException \LogicException */ public function testRenderPlainWithNestedRenderRoot() { - list($complex_child_markup, $parent_markup, $complex_child_template) = $this->setupRenderPlainComplexElements(); + list($complex_child_markup, $parent_markup, $complex_child_template) = $this->setUpRenderPlainComplexElements(); $renderer = $this->renderer; $this->setUpRequest(); - // Case 1: ::renderRoot() with nested ::renderRoot(). - // 'Renderer::renderRoot() may not be called inside of another Renderer::renderRoot() call, this must trigger an exception.'); $complex_child = $complex_child_template; $callable = function () use ($renderer, $complex_child) { $renderer->renderRoot($complex_child); @@ -75,13 +77,20 @@ public function testRenderPlainWithNestedRenderRoot() { $renderer->renderRoot($page); } + /** + * ::render() may be called from anywhere. + * + * Including from inside of another ::renderRoot() call. Bubbling must be + * performed. + * + * @covers ::renderRoot + * @covers ::render + */ public function testRenderPlainWithNestedRender() { - list($complex_child_markup, $parent_markup, $complex_child_template) = $this->setupRenderPlainComplexElements(); + list($complex_child_markup, $parent_markup, $complex_child_template) = $this->setUpRenderPlainComplexElements(); $renderer = $this->renderer; $this->setUpRequest(); - // Case 2: ::renderRoot() with nested ::render(). - // Renderer::render() may be called from anywhere, including from inside of another Renderer::renderRoot() call. Bubbling must be performed.'); $complex_child = $complex_child_template; $callable = function ($elements) use ($renderer, $complex_child, $complex_child_markup, $parent_markup) { @@ -113,13 +122,19 @@ public function testRenderPlainWithNestedRender() { $this->assertTrue(in_array('core/drupal', $page['#attached']['library']), 'Asset bubbling performed.'); } + /** + * ::renderPlain() may be called from anywhere. + * + * Including from inside of another ::renderRoot() call. + * + * @covers ::renderRoot + * @covers ::renderPlain + */ public function testRenderPlainWithNestedRenderPlain() { - list($complex_child_markup, $parent_markup, $complex_child_template) = $this->setupRenderPlainComplexElements(); + list($complex_child_markup, $parent_markup, $complex_child_template) = $this->setUpRenderPlainComplexElements(); $renderer = $this->renderer; $this->setUpRequest(); - // Case 3: ::renderRoot() with nested ::renderPlain(). - // 'Renderer::renderPlain() may be called from anywhere, including from inside of another Renderer::renderRoot() call.'); $complex_child = $complex_child_template; $callable = function ($elements) use ($renderer, $complex_child, $parent_markup) {