public function MultipleAssetLibraryTest::testAssetLibraryLocal in Libraries API 8.3
Tests that a local asset library is registered as a core asset library.
File
- tests/
src/ Kernel/ ExternalLibrary/ Asset/ MultipleAssetLibraryTest.php, line 111
Class
- MultipleAssetLibraryTest
- Tests that external asset libraries can register multiple core libraries.
Namespace
Drupal\Tests\libraries\Kernel\ExternalLibrary\AssetCode
public function testAssetLibraryLocal() {
$this->container
->set('stream_wrapper.asset_libraries', new TestLibraryFilesStream($this->container
->get('module_handler'), $this->container
->get('string_translation'), 'assets/vendor'));
$this->coreLibraryDiscovery
->clearCachedDefinitions();
$library = $this->coreLibraryDiscovery
->getLibraryByName('libraries', 'test_asset_multiple_library.first');
$expected = [
'version' => '1.0.0',
'css' => [
[
'weight' => -200,
'group' => 0,
'type' => 'file',
'data' => $this->modulePath . '/tests/assets/vendor/test_asset_multiple_library/example.first.css',
'version' => '1.0.0',
],
],
'js' => [
[
'group' => -100,
'type' => 'file',
'data' => $this->modulePath . '/tests/assets/vendor/test_asset_multiple_library/example.first.js',
'version' => '1.0.0',
'minified' => FALSE,
],
],
'dependencies' => [],
'license' => [
'name' => 'GNU-GPL-2.0-or-later',
'url' => 'https://www.drupal.org/licensing/faq',
'gpl-compatible' => TRUE,
],
];
$this
->assertEquals($expected, $library);
$library = $this->coreLibraryDiscovery
->getLibraryByName('libraries', 'test_asset_multiple_library.second');
$expected = [
'version' => '1.0.0',
'css' => [
[
'weight' => -200,
'group' => 0,
'type' => 'file',
'data' => $this->modulePath . '/tests/assets/vendor/test_asset_multiple_library/example.second.css',
'version' => '1.0.0',
],
],
'js' => [
[
'group' => -100,
'type' => 'file',
'data' => $this->modulePath . '/tests/assets/vendor/test_asset_multiple_library/example.second.js',
'version' => '1.0.0',
'minified' => FALSE,
],
],
'dependencies' => [],
'license' => [
'name' => 'GNU-GPL-2.0-or-later',
'url' => 'https://www.drupal.org/licensing/faq',
'gpl-compatible' => TRUE,
],
];
$this
->assertEquals($expected, $library);
}