Commit e8f1dc81 authored by catch's avatar catch

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

(cherry picked from commit a80a4795)
parent d5f6fa39
......@@ -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
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment