You are here

public function KernelTestBaseTest::testRenderWithTheme in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/KernelTests/KernelTestBaseTest.php \Drupal\KernelTests\KernelTestBaseTest::testRenderWithTheme()

@covers ::render

File

core/tests/Drupal/KernelTests/KernelTestBaseTest.php, line 196
Contains \Drupal\KernelTests\KernelTestBaseTest.

Class

KernelTestBaseTest
@coversDefaultClass \Drupal\KernelTests\KernelTestBase @group PHPUnit

Namespace

Drupal\KernelTests

Code

public function testRenderWithTheme() {
  $this
    ->enableModules(array(
    'system',
  ));
  $build = array(
    '#type' => 'textfield',
    '#name' => 'test',
  );
  $expected = '/' . preg_quote('<input type="text" name="test"', '/') . '/';
  $this
    ->assertArrayNotHasKey('theme', $GLOBALS);
  $output = \Drupal::service('renderer')
    ->renderRoot($build);
  $this
    ->assertEquals('core', \Drupal::theme()
    ->getActiveTheme()
    ->getName());
  $this
    ->assertRegExp($expected, (string) $build['#children']);
  $this
    ->assertRegExp($expected, (string) $output);
}