diff --git a/core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php b/core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php index 1a5cbae18f..b81bc8059d 100644 --- a/core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php +++ b/core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php @@ -21,7 +21,13 @@ class UpdateScriptTest extends BrowserTestBase { * * @var array */ - public static $modules = ['update_script_test', 'dblog', 'language']; + public static $modules = [ + 'update_script_test', + 'dblog', + 'language', + 'test_module_required_by_theme', + 'test_another_module_required_by_theme', + ]; /** * {@inheritdoc} @@ -50,7 +56,11 @@ class UpdateScriptTest extends BrowserTestBase { protected function setUp() { parent::setUp(); $this->updateUrl = Url::fromRoute('system.db_update'); - $this->updateUser = $this->drupalCreateUser(['administer software updates', 'access site in maintenance mode']); + $this->updateUser = $this->drupalCreateUser([ + 'administer software updates', + 'access site in maintenance mode', + 'administer themes', + ]); } /** @@ -164,6 +174,31 @@ public function testRequirements() { $this->drupalGet($this->updateUrl, ['external' => TRUE]); $this->assertSession()->assertEscaped('Node (Version <7.x-0.0-dev required)'); $this->assertSession()->responseContains('Update script test requires this module and version. Currently using Node version ' . \Drupal::VERSION); + + // Test that issues with modules that themes depend on are properly + // displayed. + $this->assertSession()->responseNotContains('Test Module Required by Theme'); + $this->drupalGet('admin/appearance'); + $this->getSession()->getPage()->clickLink('Install Test Theme Depending on Modules theme'); + $this->assertSession()->addressEquals('admin/appearance'); + $this->assertSession()->pageTextContains('The Test Theme Depending on Modules theme has been installed'); + + // Ensure that when a theme depends on a module and that module's + // requirements change, errors are displayed in the same manner as modules + // depending on other modules. + \Drupal::state()->set('test_theme_depending_on_modules.system_info_alter', ['dependencies' => ['test_module_required_by_theme (<7.x-0.0-dev)']]); + $this->drupalGet($this->updateUrl, ['external' => TRUE]); + $this->assertSession()->assertEscaped('Test Module Required by Theme (Version <7.x-0.0-dev required)'); + $this->assertSession()->responseContains('Test Theme Depending on Modules requires this module and version. Currently using Test Module Required by Theme version ' . \Drupal::VERSION); + + // Ensure that when a theme is updated to depend on an unavailable module, + // errors are displayed in the same manner as modules depending on other + // modules. + \Drupal::state()->set('test_theme_depending_on_modules.system_info_alter', ['dependencies' => ['a_module_theme_needs_that_does_not_exist']]); + $this->drupalGet($this->updateUrl, ['external' => TRUE]); + $this->assertSession()->responseContains('a_module_theme_needs_that_does_not_exist (Missing)'); + $this->assertSession()->responseContains('Test Theme Depending on Modules requires this module.'); + } /** diff --git a/core/modules/system/tests/themes/test_theme_depending_on_modules/test_module_required_by_theme/test_module_required_by_theme.module b/core/modules/system/tests/themes/test_theme_depending_on_modules/test_module_required_by_theme/test_module_required_by_theme.module new file mode 100644 index 0000000000..4f43f996e5 --- /dev/null +++ b/core/modules/system/tests/themes/test_theme_depending_on_modules/test_module_required_by_theme/test_module_required_by_theme.module @@ -0,0 +1,20 @@ +getName() == 'test_theme_depending_on_modules') { + $new_info = \Drupal::state()->get('test_theme_depending_on_modules.system_info_alter'); + if ($new_info) { + $info = $new_info + $info; + } + } +}