public function KernelTestBaseTest::testRenderWithTheme in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/KernelTestBaseTest.php \Drupal\KernelTests\KernelTestBaseTest::testRenderWithTheme()
@covers ::render
File
- core/
tests/ Drupal/ KernelTests/ KernelTestBaseTest.php, line 219
Class
- KernelTestBaseTest
- @coversDefaultClass \Drupal\KernelTests\KernelTestBase
Namespace
Drupal\KernelTestsCode
public function testRenderWithTheme() {
$this
->enableModules([
'system',
]);
$build = [
'#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
->assertMatchesRegularExpression($expected, (string) $build['#children']);
$this
->assertMatchesRegularExpression($expected, (string) $output);
}