function AttachedAssetsTest::testVersionQueryString
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Asset/AttachedAssetsTest.php \Drupal\KernelTests\Core\Asset\AttachedAssetsTest::testVersionQueryString()
- 8.9.x core/tests/Drupal/KernelTests/Core/Asset/AttachedAssetsTest.php \Drupal\KernelTests\Core\Asset\AttachedAssetsTest::testVersionQueryString()
- 11.x 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 264
Class
- AttachedAssetsTest
- Tests #attached assets: attached asset libraries and JavaScript settings.
Namespace
Drupal\KernelTests\Core\AssetCode
public function testVersionQueryString() : void {
$build['#attached']['library'][] = 'core/once';
$assets = AttachedAssets::createFromRenderArray($build);
$js = $this->assetResolver
->getJsAssets($assets, FALSE, \Drupal::languageManager()->getCurrentLanguage())[1];
$js_render_array = \Drupal::service('asset.js.collection_renderer')->render($js);
$rendered_js = (string) $this->renderer
->renderInIsolation($js_render_array);
$this->assertStringContainsString('core/assets/vendor/once/once.min.js?v=1.0.1', $rendered_js, 'JavaScript version identifiers correctly appended to URLs');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.