You are here

public function ThemeInstallerTest::testUninstallBaseBeforeSubTheme in Drupal 10

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

Tests uninstalling a base theme before its sub-theme.

File

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

Class

ThemeInstallerTest
Tests installing and uninstalling of themes.

Namespace

Drupal\KernelTests\Core\Theme

Code

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

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