You are here

protected function LibraryDiscoveryIntegrationTest::activateTheme in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Asset/LibraryDiscoveryIntegrationTest.php \Drupal\system\Tests\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.

7 calls to LibraryDiscoveryIntegrationTest::activateTheme()
LibraryDiscoveryIntegrationTest::testBaseThemeLibrariesOverrideInSubTheme in core/modules/system/src/Tests/Asset/LibraryDiscoveryIntegrationTest.php
Tests that base theme libraries-override still apply in sub themes.
LibraryDiscoveryIntegrationTest::testHookLibraryInfoByTheme in core/modules/system/src/Tests/Asset/LibraryDiscoveryIntegrationTest.php
Tests that hook_library_info is invoked and the cache is cleared.
LibraryDiscoveryIntegrationTest::testLibrariesExtend in core/modules/system/src/Tests/Asset/LibraryDiscoveryIntegrationTest.php
Tests libraries-extend.
LibraryDiscoveryIntegrationTest::testLibrariesOverride in core/modules/system/src/Tests/Asset/LibraryDiscoveryIntegrationTest.php
Tests that libraries-override are applied to library definitions.
LibraryDiscoveryIntegrationTest::testLibrariesOverrideDrupalSettings in core/modules/system/src/Tests/Asset/LibraryDiscoveryIntegrationTest.php
Tests libraries-override on drupalSettings.

... See full list

File

core/modules/system/src/Tests/Asset/LibraryDiscoveryIntegrationTest.php, line 224
Contains \Drupal\system\Tests\Asset\LibraryDiscoveryIntegrationTest.

Class

LibraryDiscoveryIntegrationTest
Tests the library discovery and library discovery parser.

Namespace

Drupal\system\Tests\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();

  // Assert message.
  $this
    ->pass(sprintf('Activated theme "%s"', $theme_name));
}