diff --git a/core/lib/Drupal/Core/Extension/ThemeInstaller.php b/core/lib/Drupal/Core/Extension/ThemeInstaller.php index c6d6106..70a9eac 100644 --- a/core/lib/Drupal/Core/Extension/ThemeInstaller.php +++ b/core/lib/Drupal/Core/Extension/ThemeInstaller.php @@ -221,7 +221,7 @@ public function uninstall(array $theme_list) { $list = $this->themeHandler->listInfo(); foreach ($theme_list as $key) { if (!isset($list[$key])) { - throw new UninstalledExtensionException("Unknown theme: $key."); + throw new UnknownExtensionException("Unknown theme: $key."); } if ($key === $theme_config->get('default')) { throw new \InvalidArgumentException("The current default theme $key cannot be uninstalled."); diff --git a/core/lib/Drupal/Core/Extension/ThemeInstallerInterface.php b/core/lib/Drupal/Core/Extension/ThemeInstallerInterface.php index a37c432..ff9b95e 100644 --- a/core/lib/Drupal/Core/Extension/ThemeInstallerInterface.php +++ b/core/lib/Drupal/Core/Extension/ThemeInstallerInterface.php @@ -37,9 +37,12 @@ public function install(array $theme_list, $install_dependencies = TRUE); * @param array $theme_list * The themes to uninstall. * - * @throws \Drupal\Core\Extension\UninstalledExtensionException + * @throws \Drupal\Core\Extension\UnknownExtensionException * Thrown when trying to uninstall a theme that was not installed. * + * @throws \InvalidArgumentException + * Thrown when trying to uninstall the default theme or the admin theme. + * * @see hook_themes_uninstalled() */ public function uninstall(array $theme_list); diff --git a/core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php b/core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php index 61f6475..795a51d 100644 --- a/core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php +++ b/core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php @@ -4,6 +4,7 @@ use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\Extension\ExtensionNameLengthException; +use Drupal\Core\Extension\UnknownExtensionException; use Drupal\KernelTests\KernelTestBase; /** @@ -110,11 +111,11 @@ public function testInstallNonExisting() { $this->assertFalse(array_keys($themes)); try { - $message = 'ThemeHandler::install() throws InvalidArgumentException upon installing a non-existing theme.'; + $message = 'ThemeHandler::install() throws UnknownExtensionException upon installing a non-existing theme.'; $this->themeInstaller()->install([$name]); $this->fail($message); } - catch (\InvalidArgumentException $e) { + catch (UnknownExtensionException $e) { $this->pass(get_class($e) . ': ' . $e->getMessage()); } @@ -247,11 +248,11 @@ public function testUninstallNonExisting() { $this->assertFalse(array_keys($themes)); try { - $message = 'ThemeHandler::uninstall() throws InvalidArgumentException upon uninstalling a non-existing theme.'; + $message = 'ThemeHandler::uninstall() throws UnknownExtensionException upon uninstalling a non-existing theme.'; $this->themeInstaller()->uninstall([$name]); $this->fail($message); } - catch (\InvalidArgumentException $e) { + catch (UnknownExtensionException $e) { $this->pass(get_class($e) . ': ' . $e->getMessage()); } @@ -291,11 +292,11 @@ public function testUninstallNotInstalled() { $name = 'test_basetheme'; try { - $message = 'ThemeHandler::uninstall() throws InvalidArgumentException upon uninstalling a theme that is not installed.'; + $message = 'ThemeHandler::uninstall() throws UnknownExtensionException upon uninstalling a theme that is not installed.'; $this->themeInstaller()->uninstall([$name]); $this->fail($message); } - catch (\InvalidArgumentException $e) { + catch (UnknownExtensionException $e) { $this->pass(get_class($e) . ': ' . $e->getMessage()); } }