You are here

public function RendererTest::testRenderBasic in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Render/RendererTest.php \Drupal\Tests\Core\Render\RendererTest::testRenderBasic()

@covers ::render @covers ::doRender

@dataProvider providerTestRenderBasic

File

core/tests/Drupal/Tests/Core/Render/RendererTest.php, line 43
Contains \Drupal\Tests\Core\Render\RendererTest.

Class

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

Namespace

Drupal\Tests\Core\Render

Code

public function testRenderBasic($build, $expected, callable $setup_code = NULL) {
  if (isset($setup_code)) {
    $setup_code = $setup_code
      ->bindTo($this);
    $setup_code();
  }
  if (isset($build['#markup'])) {
    $this
      ->assertFalse(SafeMarkup::isSafe($build['#markup']), 'The #markup value is not marked safe before rendering.');
  }
  $render_output = $this->renderer
    ->renderRoot($build);
  $this
    ->assertSame($expected, (string) $render_output);
  if ($render_output !== '') {
    $this
      ->assertTrue(SafeMarkup::isSafe($render_output), 'Output of render is marked safe.');
    $this
      ->assertTrue(SafeMarkup::isSafe($build['#markup']), 'The #markup value is marked safe after rendering.');
  }
}