function LayoutPluginManagerTest::activateTheme

Same name in other branches
  1. 11.x core/tests/Drupal/KernelTests/Core/Layout/LayoutPluginManagerTest.php \Drupal\KernelTests\Core\Layout\LayoutPluginManagerTest::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.

1 call to LayoutPluginManagerTest::activateTheme()
LayoutPluginManagerTest::setUp in core/tests/Drupal/KernelTests/Core/Layout/LayoutPluginManagerTest.php

File

core/tests/Drupal/KernelTests/Core/Layout/LayoutPluginManagerTest.php, line 51

Class

LayoutPluginManagerTest
@coversDefaultClass \Drupal\Core\Layout\LayoutPluginManager @group Layout

Namespace

Drupal\KernelTests\Core\Layout

Code

protected function activateTheme(string $theme_name) : void {
    $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->assertSame($theme_name, $theme_manager->getActiveTheme()
        ->getName());
}

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