diff --git a/core/modules/system/tests/modules/deprecated_module_with_non_deprecated_dependency/deprecated_module_with_non_deprecated_dependency.info.yml b/core/modules/system/tests/modules/deprecated_module_with_non_deprecated_dependency/deprecated_module_with_non_deprecated_dependency.info.yml new file mode 100644 index 0000000000000000000000000000000000000000..25830f763ef082822ecbe1b34f91daa582e026a3 --- /dev/null +++ b/core/modules/system/tests/modules/deprecated_module_with_non_deprecated_dependency/deprecated_module_with_non_deprecated_dependency.info.yml @@ -0,0 +1,9 @@ +name: Deprecated module with non deprecated dependency +type: module +description: 'Deprecated module with non deprecated dependency' +package: Testing +version: VERSION +lifecycle: deprecated +lifecycle_link: 'http://example.com/deprecated' +dependencies: + - drupal:drupal_system_listing_compatible_test diff --git a/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php b/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php index f2fca213dae06a4b0444c9d5aeb6642bab98d896..1235411a34fa35a84c777ee6d7c33d3b53885b17 100644 --- a/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php +++ b/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php @@ -121,6 +121,17 @@ public function testInstallUninstall() { } $this->submitForm([], 'Continue'); } + // Handle deprecated modules, which require a confirmation screen. + elseif ($lifecycle === ExtensionLifecycle::DEPRECATED) { + $this->assertSession()->pageTextContains('Are you sure you wish to enable a deprecated module?'); + if (count($modules_to_install) > 1) { + // When there are deprecated modules, needed dependencies do not + // result in the same page title, but there will be expected text + // indicating they need to be enabled. + $this->assertSession()->pageTextContains('You must enable'); + } + $this->submitForm([], 'Continue'); + } // Handle the case where modules were installed along with this one and // where we therefore hit a confirmation screen. elseif (count($modules_to_install) > 1) { diff --git a/core/modules/system/tests/src/Functional/Module/NonStableModulesTest.php b/core/modules/system/tests/src/Functional/Module/NonStableModulesTest.php index c90cfd486f49ba543bdbaaca7ce607507a0cf7a7..5629983d8ee93408509f84b867b8b14b5b79a82d 100644 --- a/core/modules/system/tests/src/Functional/Module/NonStableModulesTest.php +++ b/core/modules/system/tests/src/Functional/Module/NonStableModulesTest.php @@ -250,6 +250,45 @@ public function testDeprecatedConfirmForm(): void { 'deprecated_module_dependency', ]); + // Check a deprecated module with a non-deprecated dependency. + $edit = []; + $edit["modules[deprecated_module_with_non_deprecated_dependency][enable]"] = TRUE; + $this->drupalGet('admin/modules'); + $this->submitForm($edit, 'Install'); + + // The module should not be enabled and there should be a warning and a + // list of the deprecated modules with only this one. + $assert->pageTextNotContains('2 modules have been enabled: Deprecated module with non deprecated dependency, Drupal system listing compatible test'); + $assert->pageTextContains('Deprecated modules are modules that may be removed from the next major release of Drupal core. Use at your own risk.'); + $assert->pageTextContains('The Deprecated module with non deprecated dependency module is deprecated'); + $more_information_link = $assert->elementExists('named', [ + 'link', + 'The Deprecated module with non deprecated dependency module is deprecated. (more information)', + ]); + $this->assertEquals('http://example.com/deprecated', $more_information_link->getAttribute('href')); + + // There should be a warning about enabling deprecated modules, but no + // warnings about experimental modules. + $this->assertSession()->pageTextContains('Are you sure you wish to enable a deprecated module?'); + $this->assertSession()->pageTextNotContains('Are you sure you wish to enable an experimental module?'); + $this->assertSession()->pageTextNotContains('Are you sure you wish to enable experimental and deprecated modules?'); + + // Ensure the non-deprecated dependency module is not listed as deprecated. + $assert->pageTextNotContains('The Drupal system listing compatible test module is deprecated'); + + // There should be a message about enabling dependencies. + $assert->pageTextContains('You must enable the Drupal system listing compatible test module to install Deprecated module with non deprecated dependency.'); + + // Enable the module and confirm that it worked. + $this->submitForm([], 'Continue'); + $assert->pageTextContains('2 modules have been enabled: Deprecated module with non deprecated dependency, Drupal system listing compatible test.'); + + // Uninstall the modules. + \Drupal::service('module_installer')->uninstall([ + 'deprecated_module_with_non_deprecated_dependency', + 'drupal_system_listing_compatible_test', + ]); + // Finally, check both the module and its deprecated dependency. There is // still a warning about deprecated modules, but no message about // dependencies, since the user specifically enabled the dependency.