function AttachedAssetsTest::testLibraryBefore
Tests using 'before' in library definition.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Asset/ AttachedAssetsTest.php, line 382
Class
- AttachedAssetsTest
- Tests #attached assets: attached asset libraries and JavaScript settings.
Namespace
Drupal\KernelTests\Core\AssetCode
public function testLibraryBefore() : void {
$build['#attached']['library'][] = 'common_test/main';
$build['#attached']['library'][] = 'common_test/before_main';
$assets = AttachedAssets::createFromRenderArray($build);
$js = $this->assetResolver
->getJsAssets($assets, FALSE)[1];
$js_render_array = \Drupal::service('asset.js.collection_renderer')->render($js);
$rendered_js = (string) $this->renderer
->renderInIsolation($js_render_array);
$this->assertLessThan(strpos($rendered_js, 'common_test/main.js'), strpos($rendered_js, 'common_test/before_main.js'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.