You are here

protected function ResolvedLibraryDefinitionsFilesMatchTest::verifyLibraryFilesExist in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php \Drupal\system\Tests\Asset\ResolvedLibraryDefinitionsFilesMatchTest::verifyLibraryFilesExist()

Checks that all the library files exist.

Parameters

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

1 call to ResolvedLibraryDefinitionsFilesMatchTest::verifyLibraryFilesExist()
ResolvedLibraryDefinitionsFilesMatchTest::testCoreLibraryCompleteness in core/modules/system/src/Tests/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php
Ensures that all core module and theme library files exist.

File

core/modules/system/src/Tests/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php, line 146
Contains \Drupal\system\Tests\Asset\ResolvedLibraryDefinitionsFilesMatchTest.

Class

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

Namespace

Drupal\system\Tests\Asset

Code

protected function verifyLibraryFilesExist($library_definitions) {
  $root = \Drupal::root();
  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 = $root . '/' . $file;

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