function ThemeInstallerTest::testUninstallAdmin

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

Tests uninstalling the admin theme.

File

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

Class

ThemeInstallerTest
Tests installing and uninstalling of themes.

Namespace

Drupal\KernelTests\Core\Theme

Code

public function testUninstallAdmin() : void {
    $name = 'stark';
    $other_name = 'olivero';
    $this->themeInstaller()
        ->install([
        $name,
        $other_name,
    ]);
    $this->config('system.theme')
        ->set('admin', $name)
        ->save();
    $themes = $this->themeHandler()
        ->listInfo();
    $this->assertTrue(isset($themes[$name]));
    $this->assertTrue(isset($themes[$other_name]));
    try {
        $message = 'ThemeInstaller::uninstall() throws InvalidArgumentException upon disabling admin theme.';
        $this->themeInstaller()
            ->uninstall([
            $name,
        ]);
        $this->fail($message);
    } catch (\Exception $e) {
        $this->assertInstanceOf(\InvalidArgumentException::class, $e);
    }
    $themes = $this->themeHandler()
        ->listInfo();
    $this->assertTrue(isset($themes[$name]));
    $this->assertTrue(isset($themes[$other_name]));
}

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