You are here

function ThemeInstallerTest::testUninstallBaseBeforeSubTheme 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::testUninstallBaseBeforeSubTheme()

Tests uninstalling a base theme before its sub-theme.

File

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

Class

ThemeInstallerTest
Tests installing and uninstalling of themes.

Namespace

Drupal\system\Tests\Extension

Code

function testUninstallBaseBeforeSubTheme() {
  $name = 'test_basetheme';
  $sub_name = 'test_subtheme';
  $this
    ->themeInstaller()
    ->install(array(
    $sub_name,
  ));
  try {
    $message = 'ThemeHandler::install() throws InvalidArgumentException upon uninstalling base theme before sub theme.';
    $this
      ->themeInstaller()
      ->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[$sub_name]));

  // Verify that uninstalling both at the same time works.
  $this
    ->themeInstaller()
    ->uninstall(array(
    $name,
    $sub_name,
  ));
  $themes = $this
    ->themeHandler()
    ->listInfo();
  $this
    ->assertFalse(isset($themes[$name]));
  $this
    ->assertFalse(isset($themes[$sub_name]));
}