You are here

protected function LibraryDiscoveryIntegrationTest::assertNoAssetInLibrary in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Asset/LibraryDiscoveryIntegrationTest.php \Drupal\KernelTests\Core\Asset\LibraryDiscoveryIntegrationTest::assertNoAssetInLibrary()

Asserts that the specified asset is not in the given library.

Parameters

string $asset: The asset file with the path for the file.

string $extension: The extension in which the $library_name 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 not found in the library.

3 calls to LibraryDiscoveryIntegrationTest::assertNoAssetInLibrary()
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.

File

core/tests/Drupal/KernelTests/Core/Asset/LibraryDiscoveryIntegrationTest.php, line 303

Class

LibraryDiscoveryIntegrationTest
Tests the library discovery and library discovery parser.

Namespace

Drupal\KernelTests\Core\Asset

Code

protected function assertNoAssetInLibrary($asset, $extension, $library_name, $sub_key, $message = NULL) {
  if (!isset($message)) {
    $message = sprintf('Asset %s not 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 $this
        ->fail($message);
    }
  }
  return TRUE;
}