You are here

protected function ResolvedLibraryDefinitionsFilesMatchTest::setUp 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::setUp()

Overrides KernelTestBase::setUp

File

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

Class

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

Namespace

Drupal\KernelTests\Core\Asset

Code

protected function setUp() {
  parent::setUp();

  // Install all core themes.
  sort($this->allThemes);
  $this->container
    ->get('theme_installer')
    ->install($this->allThemes);

  // 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') {
      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');

  // 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';
  sort($this->allModules);
  $this->container
    ->get('module_installer')
    ->install($this->allModules);
  $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');
}