public function RendererTest::testRenderTwice in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Core/Render/RendererTest.php \Drupal\Tests\Core\Render\RendererTest::testRenderTwice()
- 10 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 636 - Contains \Drupal\Tests\Core\Render\RendererTest.
Class
- RendererTest
- @coversDefaultClass \Drupal\Core\Render\Renderer @group Render
Namespace
Drupal\Tests\Core\RenderCode
public function testRenderTwice($build) {
$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));
}