Unverified Commit b8c09bea authored by alexpott's avatar alexpott

Issue #2594669 by Wim Leers, borisson_, catch, dawehner:...

Issue #2594669 by Wim Leers, borisson_, catch, dawehner: LibraryDependencyResolver::getMinimalRepresentativeSubset() accepts a set as the input but doesn't complain if it's not actually a set
parent 246a31c4
......@@ -65,6 +65,8 @@ protected function doGetDependencies(array $libraries_with_unresolved_dependenci
* {@inheritdoc}
*/
public function getMinimalRepresentativeSubset(array $libraries) {
assert(count($libraries) === count(array_unique($libraries)), '$libraries can\'t contain duplicate items.');
$minimal = [];
// Determine each library's dependencies.
......
......@@ -766,10 +766,10 @@ function system_js_settings_alter(&$settings, AttachedAssetsInterface $assets) {
}
// Provide the page with information about the individual asset libraries
// used, information not otherwise available when aggregation is enabled.
$minimal_libraries = $library_dependency_resolver->getMinimalRepresentativeSubset(array_merge(
$minimal_libraries = $library_dependency_resolver->getMinimalRepresentativeSubset(array_unique(array_merge(
$assets->getLibraries(),
$assets->getAlreadyLoadedLibraries()
));
)));
sort($minimal_libraries);
$settings['ajaxPageState']['libraries'] = implode(',', $minimal_libraries);
}
......
......@@ -169,4 +169,12 @@ public function testGetMinimalRepresentativeSubset(array $libraries, array $expe
$this->assertEquals($expected, $this->libraryDependencyResolver->getMinimalRepresentativeSubset($libraries));
}
/**
* @covers ::getMinimalRepresentativeSubset
*/
public function testGetMinimalRepresentativeSubsetInvalidInput() {
$this->setExpectedException(\AssertionError::class, '$libraries can\'t contain duplicate items.');
$this->libraryDependencyResolver->getMinimalRepresentativeSubset(['test/no_deps_a', 'test/no_deps_a']);
}
}
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