function ThemeInstallerTest::testInstallSubTheme

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

Tests installing a sub-theme.

File

core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php, line 90

Class

ThemeInstallerTest
Tests installing and uninstalling of themes.

Namespace

Drupal\KernelTests\Core\Theme

Code

public function testInstallSubTheme() : void {
    $name = 'test_child_theme';
    $base_name = 'test_parent_theme';
    $themes = $this->themeHandler()
        ->listInfo();
    $this->assertEmpty(array_keys($themes));
    $this->themeInstaller()
        ->install([
        $name,
    ]);
    $themes = $this->themeHandler()
        ->listInfo();
    $this->assertTrue(isset($themes[$name]));
    $this->assertTrue(isset($themes[$base_name]));
    $expectedOrder = [
        $base_name,
        $name,
    ];
    $this->assertEquals($expectedOrder, array_keys($themes));
    $this->themeInstaller()
        ->uninstall([
        $name,
    ]);
    $themes = $this->themeHandler()
        ->listInfo();
    $this->assertFalse(isset($themes[$name]));
    $this->assertTrue(isset($themes[$base_name]));
}

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