function JqueryUiLibraryAssetsTest::testProperlySetWeights
Same name in other branches
- 10 core/tests/Drupal/FunctionalTests/Libraries/JqueryUiLibraryAssetsTest.php \Drupal\FunctionalTests\Libraries\JqueryUiLibraryAssetsTest::testProperlySetWeights()
- 11.x core/tests/Drupal/FunctionalTests/Libraries/JqueryUiLibraryAssetsTest.php \Drupal\FunctionalTests\Libraries\JqueryUiLibraryAssetsTest::testProperlySetWeights()
Confirm assets are weighted so they load in the correct order.
The configured loading order is compared against the necessary loading order. The necessary loading order was determined by the requirements specified in each jQuery UI JavaScript file.
File
-
core/
tests/ Drupal/ FunctionalTests/ Libraries/ JqueryUiLibraryAssetsTest.php, line 102
Class
- JqueryUiLibraryAssetsTest
- Tests the loading of jQuery UI CSS and JS assets.
Namespace
Drupal\FunctionalTests\LibrariesCode
public function testProperlySetWeights() {
$assets = [];
// Confirm that no asset is assigned multiple weights.
foreach ($this->weightGroupedAssets as $asset_array) {
foreach ($asset_array as $asset) {
$this->assertNotContains($asset, $assets);
$assets[] = $asset;
}
}
// The loading order that assets groups must be in, based on the
// dependencies specified in every jQuery UI JavaScript file.
$necessary_loading_order = [
[
'core/assets/vendor/jquery.ui/ui/version-min.js',
],
[
'core/assets/vendor/jquery.ui/ui/data-min.js',
'core/assets/vendor/jquery.ui/ui/disable-selection-min.js',
'core/assets/vendor/jquery.ui/ui/focusable-min.js',
'core/assets/vendor/jquery.ui/ui/form-min.js',
'core/assets/vendor/jquery.ui/ui/ie-min.js',
'core/assets/vendor/jquery.ui/ui/jquery-patch-min.js',
'core/assets/vendor/jquery.ui/ui/keycode-min.js',
'core/assets/vendor/jquery.ui/ui/plugin-min.js',
'core/assets/vendor/jquery.ui/ui/safe-active-element-min.js',
'core/assets/vendor/jquery.ui/ui/safe-blur-min.js',
'core/assets/vendor/jquery.ui/ui/scroll-parent-min.js',
'core/assets/vendor/jquery.ui/ui/unique-id-min.js',
'core/assets/vendor/jquery.ui/ui/widget-min.js',
'core/assets/vendor/jquery.ui/themes/base/core.css',
],
[
'core/assets/vendor/jquery.ui/ui/widgets/autocomplete-min.js',
'core/assets/vendor/jquery.ui/ui/labels-min.js',
'core/assets/vendor/jquery.ui/ui/widgets/menu-min.js',
'core/assets/vendor/jquery.ui/themes/base/autocomplete.css',
'core/assets/vendor/jquery.ui/themes/base/menu.css',
'core/assets/vendor/jquery.ui/ui/widgets/controlgroup-min.js',
'core/assets/vendor/jquery.ui/ui/form-reset-mixin-min.js',
'core/assets/vendor/jquery.ui/ui/widgets/mouse-min.js',
'core/assets/vendor/jquery.ui/themes/base/controlgroup.css',
],
[
'core/assets/vendor/jquery.ui/ui/widgets/checkboxradio-min.js',
'core/assets/vendor/jquery.ui/ui/widgets/draggable-min.js',
'core/assets/vendor/jquery.ui/ui/widgets/resizable-min.js',
'core/assets/vendor/jquery.ui/themes/base/checkboxradio.css',
'core/assets/vendor/jquery.ui/themes/base/resizable.css',
],
[
'core/assets/vendor/jquery.ui/ui/widgets/button-min.js',
'core/assets/vendor/jquery.ui/themes/base/button.css',
],
[
'core/assets/vendor/jquery.ui/ui/widgets/dialog-min.js',
'core/assets/vendor/jquery.ui/themes/base/dialog.css',
],
[
'core/assets/vendor/jquery.ui/themes/base/theme.css',
],
];
$configured_weights = array_keys($this->weightGroupedAssets);
// Loop through the necessary loading order and compare to the configured
// loading order.
foreach ($necessary_loading_order as $stage => $assets) {
$assets_loaded_in_stage = $this->weightGroupedAssets[$configured_weights[$stage]];
foreach ($assets as $asset) {
$this->assertContains($asset, $assets_loaded_in_stage);
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.