You are here

public function ThemeInstallerTest::testUninstallDefault in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php \Drupal\KernelTests\Core\Theme\ThemeInstallerTest::testUninstallDefault()
  2. 10 core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php \Drupal\KernelTests\Core\Theme\ThemeInstallerTest::testUninstallDefault()

Tests uninstalling the default theme.

File

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

Class

ThemeInstallerTest
Tests installing and uninstalling of themes.

Namespace

Drupal\KernelTests\Core\Theme

Code

public function testUninstallDefault() {
  $name = 'stark';
  $other_name = 'bartik';
  $this
    ->themeInstaller()
    ->install([
    $name,
    $other_name,
  ]);
  $this
    ->config('system.theme')
    ->set('default', $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 default 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]));
}