public function ModulesListFormWebTest::testInstalledIncompatibleModule in Drupal 10
Same name and namespace in other branches
- 9 core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php \Drupal\Tests\system\Functional\Form\ModulesListFormWebTest::testInstalledIncompatibleModule()
Tests that incompatible modules message is shown.
File
- core/
modules/ system/ tests/ src/ Functional/ Form/ ModulesListFormWebTest.php, line 140
Class
Namespace
Drupal\Tests\system\Functional\FormCode
public function testInstalledIncompatibleModule() {
$incompatible_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' => '*',
];
$incompatible_info = $info + [
'core_version_requirement' => '^1',
];
file_put_contents($file_path, Yaml::encode($compatible_info));
$edit = [
'modules[changing_module][enable]' => 'changing_module',
];
$this
->drupalGet('admin/modules');
$this
->submitForm($edit, 'Install');
$this
->assertSession()
->pageTextContains('Module Module that changes has been enabled.');
file_put_contents($file_path, Yaml::encode($incompatible_info));
$this
->drupalGet('admin/modules');
$this
->assertSession()
->pageTextContains($incompatible_modules_message);
file_put_contents($file_path, Yaml::encode($compatible_info));
$this
->drupalGet('admin/modules');
$this
->assertSession()
->pageTextNotContains($incompatible_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
->drupalGet('admin/modules/uninstall');
$this
->submitForm($edit, 'Uninstall');
$this
->submitForm([], 'Uninstall');
$this
->assertSession()
->pageTextContains('The selected modules have been uninstalled.');
file_put_contents($file_path, Yaml::encode($incompatible_info));
$this
->drupalGet('admin/modules');
$this
->assertSession()
->pageTextNotContains($incompatible_modules_message);
}