Skip to content
Snippets Groups Projects
Commit a80a4795 authored by catch's avatar catch
Browse files

Issue #2905429 by zrpnr, tim.plunkett, Wim Leers, Jacine: Library definitions...

Issue #2905429 by zrpnr, tim.plunkett, Wim Leers, Jacine: Library definitions containing only dependencies should be valid
parent 7eed52bf
No related branches found
No related tags found
No related merge requests found
......@@ -102,7 +102,7 @@ public function buildByExtension($extension) {
$libraries = $this->applyLibrariesOverride($libraries, $extension);
foreach ($libraries as $id => &$library) {
if (!isset($library['js']) && !isset($library['css']) && !isset($library['drupalSettings'])) {
if (!isset($library['js']) && !isset($library['css']) && !isset($library['drupalSettings']) && !isset($library['dependencies'])) {
throw new IncompleteLibraryDefinitionException(sprintf("Incomplete library definition for definition '%s' in extension '%s'", $id, $extension));
}
$library += ['dependencies' => [], 'js' => [], 'css' => []];
......
......@@ -172,7 +172,26 @@ public function testInvalidLibrariesFile() {
}
/**
* Tests that an exception is thrown when no CSS/JS/setting is specified.
* Tests that no exception is thrown when only dependencies are specified.
*
* @covers ::buildByExtension
*/
public function testBuildByExtensionWithOnlyDependencies() {
$this->moduleHandler->expects($this->atLeastOnce())
->method('moduleExists')
->with('example_module_only_dependencies')
->will($this->returnValue(TRUE));
$path = __DIR__ . '/library_test_files';
$path = substr($path, strlen($this->root) + 1);
$this->libraryDiscoveryParser->setPaths('module', 'example_module_only_dependencies', $path);
$libraries = $this->libraryDiscoveryParser->buildByExtension('example_module_only_dependencies');
$this->assertArrayHasKey('example', $libraries);
}
/**
* Tests that an exception is thrown with only the version property specified.
*
* @covers ::buildByExtension
*/
......
example:
dependencies: { }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment