function RenderTest::testDrupalRenderThemePreprocessAttached
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Render/RenderTest.php \Drupal\KernelTests\Core\Render\RenderTest::testDrupalRenderThemePreprocessAttached()
- 8.9.x core/tests/Drupal/KernelTests/Core/Render/RenderTest.php \Drupal\KernelTests\Core\Render\RenderTest::testDrupalRenderThemePreprocessAttached()
- 11.x core/tests/Drupal/KernelTests/Core/Render/RenderTest.php \Drupal\KernelTests\Core\Render\RenderTest::testDrupalRenderThemePreprocessAttached()
Tests theme preprocess functions being able to attach assets.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Render/ RenderTest.php, line 24
Class
- RenderTest
- Performs functional tests on \Drupal::service('renderer')->render().
Namespace
Drupal\KernelTests\Core\RenderCode
public function testDrupalRenderThemePreprocessAttached() : void {
\Drupal::state()->set('theme_preprocess_attached_test', TRUE);
$test_element = [
'#theme' => 'common_test_render_element',
'foo' => [
'#markup' => 'Kittens!',
],
];
\Drupal::service('renderer')->renderRoot($test_element);
$expected_attached = [
'library' => [
'test/generic_preprocess',
'test/specific_preprocess',
],
];
$this->assertEquals($expected_attached, $test_element['#attached'], 'All expected assets from theme preprocess hooks attached.');
\Drupal::state()->set('theme_preprocess_attached_test', FALSE);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.