protected function LibraryDiscoveryIntegrationTest::assertAssetInLibrary in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/KernelTests/Core/Asset/LibraryDiscoveryIntegrationTest.php \Drupal\KernelTests\Core\Asset\LibraryDiscoveryIntegrationTest::assertAssetInLibrary()
Asserts that the specified asset is in the given library.
Parameters
string $asset: The asset file with the path for the file.
string $extension: The extension in which the $library is defined.
string $library_name: Name of the library.
mixed $sub_key: The library sub key where the given asset is defined.
string $message: (optional) A message to display with the assertion.
Return value
bool TRUE if the specified asset is found in the library.
4 calls to LibraryDiscoveryIntegrationTest::assertAssetInLibrary()
- LibraryDiscoveryIntegrationTest::testBaseThemeLibrariesOverrideInSubTheme in core/
tests/ Drupal/ KernelTests/ Core/ Asset/ LibraryDiscoveryIntegrationTest.php - Tests that base theme libraries-override still apply in sub themes.
- LibraryDiscoveryIntegrationTest::testLibrariesExtend in core/
tests/ Drupal/ KernelTests/ Core/ Asset/ LibraryDiscoveryIntegrationTest.php - Tests libraries-extend.
- LibraryDiscoveryIntegrationTest::testLibrariesOverride in core/
tests/ Drupal/ KernelTests/ Core/ Asset/ LibraryDiscoveryIntegrationTest.php - Tests that libraries-override are applied to library definitions.
- LibraryDiscoveryIntegrationTest::testLibrariesOverrideOtherAssetLibraryNames in core/
tests/ Drupal/ KernelTests/ Core/ Asset/ LibraryDiscoveryIntegrationTest.php - Tests library assets with other ways for specifying paths.
File
- core/
tests/ Drupal/ KernelTests/ Core/ Asset/ LibraryDiscoveryIntegrationTest.php, line 252
Class
- LibraryDiscoveryIntegrationTest
- Tests the library discovery and library discovery parser.
Namespace
Drupal\KernelTests\Core\AssetCode
protected function assertAssetInLibrary($asset, $extension, $library_name, $sub_key, $message = NULL) {
if (!isset($message)) {
$message = sprintf('Asset %s found in library "%s/%s"', $asset, $extension, $library_name);
}
$library = $this->libraryDiscovery
->getLibraryByName($extension, $library_name);
foreach ($library[$sub_key] as $definition) {
if ($asset == $definition['data']) {
return TRUE;
}
}
return $this
->fail($message);
}