function RendererTest::testRenderBasic

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Render/RendererTest.php \Drupal\Tests\Core\Render\RendererTest::testRenderBasic()
  2. 10 core/tests/Drupal/Tests/Core/Render/RendererTest.php \Drupal\Tests\Core\Render\RendererTest::testRenderBasic()
  3. 11.x 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 44

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->assertNotInstanceOf(MarkupInterface::class, $build['#markup']);
    }
    $render_output = $this->renderer
        ->renderRoot($build);
    $this->assertSame($expected, (string) $render_output);
    if ($render_output !== '') {
        $this->assertInstanceOf(MarkupInterface::class, $render_output);
        $this->assertInstanceOf(MarkupInterface::class, $build['#markup']);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.