diff --git a/core/modules/system/tests/themes/test_theme_depending_nonexisting_module/test_theme_depending_on_nonexisting_module.info.yml b/core/modules/system/tests/themes/test_theme_depending_nonexisting_module/test_theme_depending_on_nonexisting_module.info.yml index 2499fc444c..43c8ed477b 100644 --- a/core/modules/system/tests/themes/test_theme_depending_nonexisting_module/test_theme_depending_on_nonexisting_module.info.yml +++ b/core/modules/system/tests/themes/test_theme_depending_nonexisting_module/test_theme_depending_on_nonexisting_module.info.yml @@ -1,4 +1,4 @@ -name: test theme depending on nonexisting module +name: Test Theme Depending on Nonexisting Module type: theme core: 8.x base theme: stark diff --git a/core/modules/system/tests/themes/test_theme_depending_on_modules/test_module_required_by_theme/test_module_required_by_theme.info.yml b/core/modules/system/tests/themes/test_theme_depending_on_modules/test_module_required_by_theme/test_module_required_by_theme.info.yml index 9d402c7c1d..75fcd17ae5 100644 --- a/core/modules/system/tests/themes/test_theme_depending_on_modules/test_module_required_by_theme/test_module_required_by_theme.info.yml +++ b/core/modules/system/tests/themes/test_theme_depending_on_modules/test_module_required_by_theme/test_module_required_by_theme.info.yml @@ -1,4 +1,4 @@ -name: test module required by theme +name: Test Module Required by Theme type: module core: 8.x package: Testing diff --git a/core/modules/system/tests/themes/test_theme_depending_on_modules/test_theme_depending_on_modules.info.yml b/core/modules/system/tests/themes/test_theme_depending_on_modules/test_theme_depending_on_modules.info.yml index 7edd71f3b8..a20675c742 100644 --- a/core/modules/system/tests/themes/test_theme_depending_on_modules/test_theme_depending_on_modules.info.yml +++ b/core/modules/system/tests/themes/test_theme_depending_on_modules/test_theme_depending_on_modules.info.yml @@ -1,4 +1,4 @@ -name: test theme depending on modules +name: Test Theme Depending on Modules type: theme core: 8.x base theme: stark diff --git a/core/modules/system/tests/themes/test_theme_with_a_base_theme_depending_on_modules/test_theme_with_a_base_theme_depending_on_modules.info.yml b/core/modules/system/tests/themes/test_theme_with_a_base_theme_depending_on_modules/test_theme_with_a_base_theme_depending_on_modules.info.yml index 4653fbf941..91391fdac8 100644 --- a/core/modules/system/tests/themes/test_theme_with_a_base_theme_depending_on_modules/test_theme_with_a_base_theme_depending_on_modules.info.yml +++ b/core/modules/system/tests/themes/test_theme_with_a_base_theme_depending_on_modules/test_theme_with_a_base_theme_depending_on_modules.info.yml @@ -1,4 +1,4 @@ -name: test theme with a base theme depending on modules +name: Test Theme with a Base Theme Depending on Modules type: theme core: 8.x base theme: test_theme_depending_on_modules diff --git a/core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php b/core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php index 068af6744c..e0027056be 100644 --- a/core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php +++ b/core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php @@ -106,21 +106,11 @@ public function testInstallSubTheme() { */ public function testInstallNonExisting() { $name = 'non_existing_theme'; - - $themes = $this->themeHandler()->listInfo(); - $this->assertEmpty(array_keys($themes)); - - try { - $message = 'ThemeInstaller::install() throws UnknownExtensionException upon installing a non-existing theme.'; - $this->themeInstaller()->install([$name]); - $this->fail($message); - } - catch (UnknownExtensionException $e) { - $this->pass(get_class($e) . ': ' . $e->getMessage()); - } - $themes = $this->themeHandler()->listInfo(); $this->assertEmpty(array_keys($themes)); + $this->expectException(UnknownExtensionException::class); + $this->expectExceptionMessage('Unknown themes: non_existing_theme.'); + $this->themeInstaller()->install([$name]); } /** @@ -144,15 +134,11 @@ public function testInstallNameTooLong() { */ public function testInstallThemeWithUnmetModuleDependencies() { $name = 'test_theme_depending_on_modules'; - - try { - $message = 'ThemeInstaller::install() throws MissingDependencyException upon installing a theme with unmet module dependencies.'; - $this->themeInstaller()->install([$name]); - $this->fail($message); - } - catch (MissingDependencyException $e) { - $this->pass(get_class($e) . ': ' . $e->getMessage()); - } + $themes = $this->themeHandler()->listInfo(); + $this->assertEmpty(array_keys($themes)); + $this->expectException(MissingDependencyException::class); + $this->expectExceptionMessage('Unable to install theme: \'test_theme_depending_on_modules\' due to missing module dependencies: \'test_module_required_by_theme, test_another_module_required_by_theme.'); + $this->themeInstaller()->install([$name]); } /** @@ -166,16 +152,9 @@ public function testInstallThemeWithMetModuleDependencies() { $this->themeInstaller()->install([$name]); $themes = $this->themeHandler()->listInfo(); $this->assertTrue(isset($themes[$name])); - - // Confirm that modules that active themes depend on can't be uninstalled. - try { - $message = 'Attempting to uninstall a module that an active theme depends on results in a ModuleUninstallValidatorException'; - $this->container->get('module_installer')->uninstall(['test_module_required_by_theme']); - $this->fail($message); - } - catch (ModuleUninstallValidatorException $e) { - $this->pass(get_class($e) . ': ' . $e->getMessage()); - } + $this->expectException(ModuleUninstallValidatorException::class); + $this->expectExceptionMessage('The following reasons prevent the modules from being uninstalled: Required by the theme: Test Theme Depending on Modules'); + $this->container->get('module_installer')->uninstall(['test_module_required_by_theme']); } /**