function AttachedAssetsTest::testVersionQueryString in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Common/AttachedAssetsTest.php \Drupal\system\Tests\Common\AttachedAssetsTest::testVersionQueryString()
Tests JavaScript versioning.
File
- core/
modules/ system/ src/ Tests/ Common/ AttachedAssetsTest.php, line 280 - Contains \Drupal\system\Tests\Common\AttachedAssetsTest.
Class
- AttachedAssetsTest
- Tests #attached assets: attached asset libraries and JavaScript settings.
Namespace
Drupal\system\Tests\CommonCode
function testVersionQueryString() {
$build['#attached']['library'][] = 'core/backbone';
$build['#attached']['library'][] = 'core/domready';
$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
->assertTrue(strpos($rendered_js, 'core/assets/vendor/backbone/backbone-min.js?v=1.2.3') > 0 && strpos($rendered_js, 'core/assets/vendor/domready/ready.min.js?v=1.0.8') > 0, 'JavaScript version identifiers correctly appended to URLs');
}