You are here

protected function LibraryDiscoveryIntegrationTest::activateTheme in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Asset/LibraryDiscoveryIntegrationTest.php \Drupal\KernelTests\Core\Asset\LibraryDiscoveryIntegrationTest::activateTheme()
  2. 9 core/tests/Drupal/KernelTests/Core/Asset/LibraryDiscoveryIntegrationTest.php \Drupal\KernelTests\Core\Asset\LibraryDiscoveryIntegrationTest::activateTheme()

Activates a specified theme.

Installs the theme if not already installed and makes it the active theme.

Parameters

string $theme_name: The name of the theme to be activated.

8 calls to LibraryDiscoveryIntegrationTest::activateTheme()
LibraryDiscoveryIntegrationTest::testBaseThemeLibrariesOverrideInSubTheme in core/tests/Drupal/KernelTests/Core/Asset/LibraryDiscoveryIntegrationTest.php
Tests that base theme libraries-override still apply in sub themes.
LibraryDiscoveryIntegrationTest::testDeprecatedLibrary in core/tests/Drupal/KernelTests/Core/Asset/LibraryDiscoveryIntegrationTest.php
Test deprecated libraries.
LibraryDiscoveryIntegrationTest::testHookLibraryInfoByTheme in core/tests/Drupal/KernelTests/Core/Asset/LibraryDiscoveryIntegrationTest.php
Tests that hook_library_info is invoked and the cache is cleared.
LibraryDiscoveryIntegrationTest::testLibrariesExtend in core/tests/Drupal/KernelTests/Core/Asset/LibraryDiscoveryIntegrationTest.php
Tests libraries-extend.
LibraryDiscoveryIntegrationTest::testLibrariesOverride in core/tests/Drupal/KernelTests/Core/Asset/LibraryDiscoveryIntegrationTest.php
Tests that libraries-override are applied to library definitions.

... See full list

File

core/tests/Drupal/KernelTests/Core/Asset/LibraryDiscoveryIntegrationTest.php, line 240

Class

LibraryDiscoveryIntegrationTest
Tests the library discovery and library discovery parser.

Namespace

Drupal\KernelTests\Core\Asset

Code

protected function activateTheme($theme_name) {
  $this->container
    ->get('theme_installer')
    ->install([
    $theme_name,
  ]);

  /** @var \Drupal\Core\Theme\ThemeInitializationInterface $theme_initializer */
  $theme_initializer = $this->container
    ->get('theme.initialization');

  /** @var \Drupal\Core\Theme\ThemeManagerInterface $theme_manager */
  $theme_manager = $this->container
    ->get('theme.manager');
  $theme_manager
    ->setActiveTheme($theme_initializer
    ->getActiveThemeByName($theme_name));
  $this->libraryDiscovery
    ->clearCachedDefinitions();
  $this
    ->assertSame($theme_name, $theme_manager
    ->getActiveTheme()
    ->getName());
}