You are here

protected function ResolvedLibraryDefinitionsFilesMatchTest::verifyLibraryFilesExist in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php \Drupal\KernelTests\Core\Asset\ResolvedLibraryDefinitionsFilesMatchTest::verifyLibraryFilesExist()
  2. 10 core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php \Drupal\KernelTests\Core\Asset\ResolvedLibraryDefinitionsFilesMatchTest::verifyLibraryFilesExist()

Checks that all the library files exist.

Parameters

array[] $library_definitions: An array of library definitions, keyed by extension, then by library, and so on.

1 call to ResolvedLibraryDefinitionsFilesMatchTest::verifyLibraryFilesExist()
ResolvedLibraryDefinitionsFilesMatchTest::testCoreLibraryCompleteness in core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php
Ensures that all core module and theme library files exist.

File

core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php, line 162

Class

ResolvedLibraryDefinitionsFilesMatchTest
Tests that the asset files for all core libraries exist.

Namespace

Drupal\KernelTests\Core\Asset

Code

protected function verifyLibraryFilesExist($library_definitions) {
  foreach ($library_definitions as $extension => $libraries) {
    foreach ($libraries as $library_name => $library) {
      if (in_array("{$extension}/{$library_name}", $this->librariesToSkip)) {
        continue;
      }

      // Check that all the assets exist.
      foreach ([
        'css',
        'js',
      ] as $asset_type) {
        foreach ($library[$asset_type] as $asset) {
          $file = $asset['data'];
          $path = $this->root . '/' . $file;

          // Only check and assert each file path once.
          if (!isset($this->pathsChecked[$path])) {
            $this
              ->assertFileExists($path, "{$file} file referenced from the {$extension}/{$library_name} library does not exist.");
            $this->pathsChecked[$path] = TRUE;
          }
        }
      }
    }
  }
}