function RendererTest::testRenderTwice
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Render/RendererTest.php \Drupal\Tests\Core\Render\RendererTest::testRenderTwice()
- 8.9.x core/tests/Drupal/Tests/Core/Render/RendererTest.php \Drupal\Tests\Core\Render\RendererTest::testRenderTwice()
- 11.x core/tests/Drupal/Tests/Core/Render/RendererTest.php \Drupal\Tests\Core\Render\RendererTest::testRenderTwice()
Tests rendering same render array twice.
Tests that a first render returns the rendered output and a second doesn't because of the #printed property. Also tests that correct metadata has been set for re-rendering.
@covers ::render @covers ::doRender
@dataProvider providerRenderTwice
File
-
core/
tests/ Drupal/ Tests/ Core/ Render/ RendererTest.php, line 654
Class
- RendererTest
- @coversDefaultClass \Drupal\Core\Render\Renderer @group Render
Namespace
Drupal\Tests\Core\RenderCode
public function testRenderTwice($build) : void {
$this->assertEquals('kittens', $this->renderer
->renderRoot($build));
$this->assertEquals('kittens', $build['#markup']);
$this->assertEquals([
'kittens-147',
], $build['#cache']['tags']);
$this->assertTrue($build['#printed']);
// We don't want to reprint already printed render arrays.
$this->assertEquals('', $this->renderer
->renderRoot($build));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.