function ResolvedLibraryDefinitionsFilesMatchTest::verifyLibraryFilesExist

Same name in other branches
  1. 8.9.x 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()
  3. 11.x 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 177

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;
                    }
                }
            }
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.