function JqueryUiLibraryAssetsTest::setUp
Same name in other branches
- 10 core/tests/Drupal/FunctionalTests/Libraries/JqueryUiLibraryAssetsTest.php \Drupal\FunctionalTests\Libraries\JqueryUiLibraryAssetsTest::setUp()
- 11.x core/tests/Drupal/FunctionalTests/Libraries/JqueryUiLibraryAssetsTest.php \Drupal\FunctionalTests\Libraries\JqueryUiLibraryAssetsTest::setUp()
Overrides BrowserTestBase::setUp
File
-
core/
tests/ Drupal/ FunctionalTests/ Libraries/ JqueryUiLibraryAssetsTest.php, line 52
Class
- JqueryUiLibraryAssetsTest
- Tests the loading of jQuery UI CSS and JS assets.
Namespace
Drupal\FunctionalTests\LibrariesCode
protected function setUp() : void {
parent::setUp();
$this->libraryDiscovery = $this->container
->get('library.discovery');
$core_libraries = $this->libraryDiscovery
->getLibrariesByExtension('core');
// All the core libraries that use jQuery UI assets.
$libraries_to_check = [
'drupal.autocomplete',
'drupal.dialog',
'jquery.ui',
'jquery.ui.autocomplete',
'jquery.ui.button',
'jquery.ui.dialog',
'jquery.ui.menu',
'jquery.ui.mouse',
'jquery.ui.resizable',
'jquery.ui.widget',
];
$this->coreLibrariesWithJqueryUiAssets = array_filter($core_libraries, function ($key) use ($libraries_to_check) {
return in_array($key, $libraries_to_check);
}, ARRAY_FILTER_USE_KEY);
// Loop through the core libraries with jQuery assets to build an array that
// groups assets by their weight value.
foreach ($this->coreLibrariesWithJqueryUiAssets as $library) {
foreach ([
'js',
'css',
] as $type) {
foreach ($library[$type] as $asset) {
$file = $asset['data'];
if (strpos($file, 'jquery.ui') === FALSE) {
continue;
}
$weight = $asset['weight'];
$this->weightGroupedAssets["{$weight}"][] = $file;
}
}
}
$this->weightGroupedAssets = array_map(function ($item) {
return array_unique($item);
}, $this->weightGroupedAssets);
ksort($this->weightGroupedAssets);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.