You are here

function ThemeInstallerTest::testUninstallAdmin in Zircon Profile 8.0

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

Tests uninstalling the admin theme.

File

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

Class

ThemeInstallerTest
Tests installing and uninstalling of themes.

Namespace

Drupal\system\Tests\Extension

Code

function testUninstallAdmin() {
  $name = 'stark';
  $other_name = 'bartik';
  $this
    ->themeInstaller()
    ->install(array(
    $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 = 'ThemeHandler::uninstall() throws InvalidArgumentException upon disabling admin 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]));
}