public function RendererRecursionTest::testRenderRecursionWithNestedRender in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Render/RendererRecursionTest.php \Drupal\Tests\Core\Render\RendererRecursionTest::testRenderRecursionWithNestedRender()
- 9 core/tests/Drupal/Tests/Core/Render/RendererRecursionTest.php \Drupal\Tests\Core\Render\RendererRecursionTest::testRenderRecursionWithNestedRender()
::render() may be called from anywhere.
Including from inside of another ::renderRoot() call. Bubbling must be performed.
@covers ::renderRoot @covers ::render @covers ::doRender
File
- core/
tests/ Drupal/ Tests/ Core/ Render/ RendererRecursionTest.php, line 67
Class
- RendererRecursionTest
- @coversDefaultClass \Drupal\Core\Render\Renderer @group Render
Namespace
Drupal\Tests\Core\RenderCode
public function testRenderRecursionWithNestedRender() {
[
$complex_child_markup,
$parent_markup,
$complex_child_template,
] = $this
->setUpRenderRecursionComplexElements();
$renderer = $this->renderer;
$this
->setUpRequest();
$callable = function ($markup) use ($renderer, $complex_child_template) {
$this
->assertStringStartsWith('<drupal-render-placeholder', $markup, 'Rendered complex child output as expected, without the placeholder replaced, i.e. with just the placeholder.');
return $markup;
};
$page = [
'content' => [
'complex_child' => $complex_child_template,
'#post_render' => [
$callable,
],
'#suffix' => $parent_markup,
],
];
$output = $renderer
->renderRoot($page);
$this
->assertEquals('<p>This is a rendered placeholder!</p><p>Rendered!</p>', $output, 'Rendered output as expected, with the placeholder replaced.');
$this
->assertContains('test:complex_child', $page['#cache']['tags'], 'Cache tag bubbling performed.');
$this
->assertContains('dynamic_animal', array_keys($page['#attached']['drupalSettings']), 'Asset bubbling performed.');
}