public function AttachedAssetsTest::testVersionQueryString in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Asset/AttachedAssetsTest.php \Drupal\KernelTests\Core\Asset\AttachedAssetsTest::testVersionQueryString()
Tests JavaScript versioning.
File
- core/
tests/ Drupal/ KernelTests/ Core/ Asset/ AttachedAssetsTest.php, line 285
Class
- AttachedAssetsTest
- Tests #attached assets: attached asset libraries and JavaScript settings.
Namespace
Drupal\KernelTests\Core\AssetCode
public function testVersionQueryString() {
$build['#attached']['library'][] = 'core/backbone';
$assets = AttachedAssets::createFromRenderArray($build);
$js = $this->assetResolver
->getJsAssets($assets, FALSE)[1];
$js_render_array = \Drupal::service('asset.js.collection_renderer')
->render($js);
$rendered_js = $this->renderer
->renderPlain($js_render_array);
$this
->assertStringContainsString('core/assets/vendor/backbone/backbone-min.js?v=1.4.0', $rendered_js, 'JavaScript version identifiers correctly appended to URLs');
}