public function RenderTest::testDrupalRenderThemePreprocessAttached in Drupal 8
Same name and namespace in other branches
- 9 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_render().
Namespace
Drupal\KernelTests\Core\RenderCode
public function testDrupalRenderThemePreprocessAttached() {
\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
->assertEqual($expected_attached, $test_element['#attached'], 'All expected assets from theme preprocess hooks attached.');
\Drupal::state()
->set('theme_preprocess_attached_test', FALSE);
}