function RendererRecursionTest::testRenderRecursionWithNestedRenderRoot

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Render/RendererRecursionTest.php \Drupal\Tests\Core\Render\RendererRecursionTest::testRenderRecursionWithNestedRenderRoot()
  2. 8.9.x core/tests/Drupal/Tests/Core/Render/RendererRecursionTest.php \Drupal\Tests\Core\Render\RendererRecursionTest::testRenderRecursionWithNestedRenderRoot()
  3. 11.x core/tests/Drupal/Tests/Core/Render/RendererRecursionTest.php \Drupal\Tests\Core\Render\RendererRecursionTest::testRenderRecursionWithNestedRenderRoot()

::renderRoot() may not be called inside of another ::renderRoot() call.

@covers ::renderRoot @covers ::render @covers ::doRender

File

core/tests/Drupal/Tests/Core/Render/RendererRecursionTest.php, line 37

Class

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

Namespace

Drupal\Tests\Core\Render

Code

public function testRenderRecursionWithNestedRenderRoot() : void {
    [
        $complex_child_markup,
        $parent_markup,
        $complex_child_template,
    ] = $this->setUpRenderRecursionComplexElements();
    $renderer = $this->renderer;
    $this->setUpRequest();
    $complex_child = $complex_child_template;
    $callable = function () use ($renderer, $complex_child) {
        $this->expectException(\LogicException::class);
        $renderer->renderRoot($complex_child);
    };
    $page = [
        'content' => [
            '#pre_render' => [
                $callable,
            ],
            '#suffix' => $parent_markup,
        ],
    ];
    $renderer->renderRoot($page);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.