diff --git a/core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php b/core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php index 282a180a07..fbc89780dd 100644 --- a/core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php +++ b/core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php @@ -2,6 +2,7 @@ namespace Drupal\Tests\system\Functional\Form; +use Drupal\Core\Serialization\Yaml; use Drupal\Tests\BrowserTestBase; /** @@ -121,4 +122,56 @@ public function testRequiredByThemeMessage() { $this->assertSession()->pageTextContains('Test Theme Depending on Modules (Theme) (Disabled)'); } + /** + * Tests that incompatible modules message is shown. + */ + public function testInstalledIncompatibleModule() { + $incompatitable_modules_message = 'There are errors with some installed modules. Visit the status report page for more information.'; + $path = \Drupal::getContainer()->getParameter('site.path') . "/modules/changing_module"; + mkdir($path, 0777, TRUE); + $file_path = "$path/changing_module.info.yml"; + $info = [ + 'name' => 'Module that changes', + 'type' => 'module', + ]; + $compatible_info = $info + ['core_version_requirement' => '*']; + + file_put_contents($file_path, Yaml::encode($compatible_info)); + $edit = ['modules[changing_module][enable]' => 'changing_module']; + $this->drupalGet('admin/modules'); + $this->drupalPostForm('admin/modules', $edit, t('Install')); + $this->assertText('Module Module that changes has been enabled.'); + + $incompatible_updates = [ + [ + 'core_version_requirement' => '^1', + ], + [ + 'core' => '8.x', + ], + ]; + foreach ($incompatible_updates as $incompatible_update) { + $incompatible_info = $info + $incompatible_update; + file_put_contents($file_path, Yaml::encode($incompatible_info)); + $this->drupalGet('admin/modules'); + $this->assertText($incompatitable_modules_message); + + file_put_contents($file_path, Yaml::encode($compatible_info)); + $this->drupalGet('admin/modules'); + $this->assertNoText($incompatitable_modules_message); + } + // Uninstall the module and ensure that incompatible modules message is not + // displayed for modules that are not installed. + $edit = ['uninstall[changing_module]' => 'changing_module']; + $this->drupalPostForm('admin/modules/uninstall', $edit, t('Uninstall')); + $this->drupalPostForm(NULL, NULL, t('Uninstall')); + $this->assertText('The selected modules have been uninstalled.'); + foreach ($incompatible_updates as $incompatible_update) { + $incompatible_info = $info + $incompatible_update; + file_put_contents($file_path, Yaml::encode($incompatible_info)); + $this->drupalGet('admin/modules'); + $this->assertNoText($incompatitable_modules_message); + } + } + } diff --git a/core/modules/system/tests/src/Functional/Theme/ThemeUiTest.php b/core/modules/system/tests/src/Functional/Theme/ThemeUiTest.php index d9f2d3c1a2..aa3d851684 100644 --- a/core/modules/system/tests/src/Functional/Theme/ThemeUiTest.php +++ b/core/modules/system/tests/src/Functional/Theme/ThemeUiTest.php @@ -2,6 +2,7 @@ namespace Drupal\Tests\system\Functional\Theme; +use Drupal\Core\Serialization\Yaml; use Drupal\Tests\BrowserTestBase; /** @@ -318,4 +319,59 @@ public function testInstallModuleWithIncompatibleDependencies() { $this->assertStringContainsString('This theme requires the listed modules to operate correctly.', $theme_container->getText()); } + /** + * Tests that incompatible themes message is shown. + */ + public function testInstalledIncompatibleTheme() { + $page = $this->getSession()->getPage(); + $assert_session = $this->assertSession(); + $incompatitable_themes_message = 'There are errors with some installed themes. Visit the status report page for more information.'; + $path = \Drupal::getContainer()->getParameter('site.path') . "/themes/changing_theme"; + mkdir($path, 0777, TRUE); + $file_path = "$path/changing_theme.info.yml"; + $theme_name = 'Theme that changes'; + $info = [ + 'name' => $theme_name, + 'type' => 'theme', + 'base theme' => FALSE, + ]; + + $compatible_info = $info + ['core_version_requirement' => '*']; + + file_put_contents($file_path, Yaml::encode($compatible_info)); + $this->drupalGet('admin/appearance'); + $this->assertNoText($incompatitable_themes_message); + $page->clickLink("Install $theme_name theme"); + $assert_session->addressEquals('admin/appearance'); + $assert_session->pageTextContains("The $theme_name theme has been installed"); + + $incompatible_updates = [ + [ + 'core_version_requirement' => '^1', + ], + [ + 'core' => '8.x', + ], + ]; + foreach ($incompatible_updates as $incompatible_update) { + $incompatible_info = $info + $incompatible_update; + file_put_contents($file_path, Yaml::encode($incompatible_info)); + $this->drupalGet('admin/appearance'); + $this->assertText($incompatitable_themes_message); + + file_put_contents($file_path, Yaml::encode($compatible_info)); + $this->drupalGet('admin/appearance'); + $this->assertNoText($incompatitable_themes_message); + } + // Uninstall the theme and ensure that incompatible themes message is not + // displayed for themes that are not installed. + $this->uninstallTheme($theme_name); + foreach ($incompatible_updates as $incompatible_update) { + $incompatible_info = $info + $incompatible_update; + file_put_contents($file_path, Yaml::encode($incompatible_info)); + $this->drupalGet('admin/appearance'); + $this->assertNoText($incompatitable_themes_message); + } + } + }