function ResolvedLibraryDefinitionsFilesMatchTest::setUp

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php \Drupal\KernelTests\Core\Asset\ResolvedLibraryDefinitionsFilesMatchTest::setUp()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php \Drupal\KernelTests\Core\Asset\ResolvedLibraryDefinitionsFilesMatchTest::setUp()
  3. 11.x core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php \Drupal\KernelTests\Core\Asset\ResolvedLibraryDefinitionsFilesMatchTest::setUp()

Overrides KernelTestBase::setUp

File

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

Class

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

Namespace

Drupal\KernelTests\Core\Asset

Code

protected function setUp() : void {
    parent::setUp();
    // Enable all core modules.
    $all_modules = $this->container
        ->get('extension.list.module')
        ->getList();
    $all_modules = array_filter($all_modules, function ($module) {
        // Filter contrib, hidden, already enabled modules and modules in the
        // Testing package.
        if ($module->origin !== 'core' || !empty($module->info['hidden']) || $module->status == TRUE || $module->info['package'] == 'Testing' || $module->info[ExtensionLifecycle::LIFECYCLE_IDENTIFIER] === ExtensionLifecycle::EXPERIMENTAL || $module->info[ExtensionLifecycle::LIFECYCLE_IDENTIFIER] === ExtensionLifecycle::DEPRECATED) {
            return FALSE;
        }
        return TRUE;
    });
    // Install the 'user' entity schema because the workspaces module's install
    // hook creates a workspace with default uid of 1. Then the layout_builder
    // module's implementation of hook_entity_presave will cause
    // \Drupal\Core\TypedData\Validation\RecursiveValidator::validate() to run
    // on the workspace which will fail because the user table is not present.
    // @todo Remove this in https://www.drupal.org/node/3039217.
    $this->installEntitySchema('user');
    // Install the 'path_alias' entity schema because the path alias path
    // processor requires it.
    $this->installEntitySchema('path_alias');
    // Remove demo_umami_content module as its install hook creates content
    // that relies on the presence of entity tables and various other elements
    // not present in a kernel test.
    unset($all_modules['demo_umami_content']);
    $this->allModules = array_keys($all_modules);
    $this->allModules[] = 'system';
    $this->allModules[] = 'user';
    $this->allModules[] = 'path_alias';
    $database_module = \Drupal::database()->getProvider();
    if ($database_module !== 'core') {
        $this->allModules[] = $database_module;
    }
    sort($this->allModules);
    $this->container
        ->get('module_installer')
        ->install($this->allModules);
    // Install all core themes.
    sort($this->allThemes);
    $this->container
        ->get('theme_installer')
        ->install($this->allThemes);
    $this->themeHandler = $this->container
        ->get('theme_handler');
    $this->themeInitialization = $this->container
        ->get('theme.initialization');
    $this->themeManager = $this->container
        ->get('theme.manager');
    $this->libraryDiscovery = $this->container
        ->get('library.discovery');
}

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