You are here

function ThemeInstallerTest::testUninstallDefault in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Extension/ThemeInstallerTest.php \Drupal\system\Tests\Extension\ThemeInstallerTest::testUninstallDefault()

Tests uninstalling the default theme.

File

core/modules/system/src/Tests/Extension/ThemeInstallerTest.php, line 146
Contains \Drupal\system\Tests\Extension\ThemeInstallerTest.

Class

ThemeInstallerTest
Tests installing and uninstalling of themes.

Namespace

Drupal\system\Tests\Extension

Code

function testUninstallDefault() {
  $name = 'stark';
  $other_name = 'bartik';
  $this
    ->themeInstaller()
    ->install(array(
    $name,
    $other_name,
  ));
  $this
    ->themeHandler()
    ->setDefault($name);
  $themes = $this
    ->themeHandler()
    ->listInfo();
  $this
    ->assertTrue(isset($themes[$name]));
  $this
    ->assertTrue(isset($themes[$other_name]));
  try {
    $message = 'ThemeHandler::uninstall() throws InvalidArgumentException upon disabling default theme.';
    $this
      ->themeHandler()
      ->uninstall(array(
      $name,
    ));
    $this
      ->fail($message);
  } catch (\InvalidArgumentException $e) {
    $this
      ->pass(get_class($e) . ': ' . $e
      ->getMessage());
  }
  $themes = $this
    ->themeHandler()
    ->listInfo();
  $this
    ->assertTrue(isset($themes[$name]));
  $this
    ->assertTrue(isset($themes[$other_name]));
}