function RendererPlaceholdersTest::testRecursivePlaceholder
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php \Drupal\Tests\Core\Render\RendererPlaceholdersTest::testRecursivePlaceholder()
- 8.9.x core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php \Drupal\Tests\Core\Render\RendererPlaceholdersTest::testRecursivePlaceholder()
- 11.x core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php \Drupal\Tests\Core\Render\RendererPlaceholdersTest::testRecursivePlaceholder()
Tests a placeholder that adds another placeholder.
E.g. when rendering a node in a placeholder the rendering of that node needs a placeholder of its own to be executed (to render the node links).
@covers ::render @covers ::doRender @covers ::replacePlaceholders
File
-
core/
tests/ Drupal/ Tests/ Core/ Render/ RendererPlaceholdersTest.php, line 806
Class
- RendererPlaceholdersTest
- @coversDefaultClass \Drupal\Core\Render\Renderer @covers \Drupal\Core\Render\RenderCache @covers \Drupal\Core\Render\PlaceholderingRenderCache @group Render
Namespace
Drupal\Tests\Core\RenderCode
public function testRecursivePlaceholder() : void {
$args = [
static::randomContextValue(),
];
$element = [];
$element['#create_placeholder'] = TRUE;
$element['#lazy_builder'] = [
'Drupal\\Tests\\Core\\Render\\RecursivePlaceholdersTest::callback',
$args,
];
$output = $this->renderer
->renderRoot($element);
$this->assertEquals('<p>This is a rendered placeholder!</p>', $output, 'The output has been modified by the indirect, recursive placeholder #lazy_builder callback.');
$this->assertSame((string) $element['#markup'], '<p>This is a rendered placeholder!</p>', '#markup is overridden by the indirect, recursive placeholder #lazy_builder callback.');
$expected_js_settings = [
'dynamic_animal' => $args[0],
];
$this->assertSame($element['#attached']['drupalSettings'], $expected_js_settings, '#attached is modified by the indirect, recursive placeholder #lazy_builder callback.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.