You are here

function RenderTest::testDrupalRenderThemePreprocessAttached in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Common/RenderTest.php \Drupal\system\Tests\Common\RenderTest::testDrupalRenderThemePreprocessAttached()

Tests theme preprocess functions being able to attach assets.

File

core/modules/system/src/Tests/Common/RenderTest.php, line 30
Contains \Drupal\system\Tests\Common\RenderTest.

Class

RenderTest
Performs functional tests on drupal_render().

Namespace

Drupal\system\Tests\Common

Code

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);
}