function DependencyTest::testNoVersionInfo
Same name in other branches
- 10 core/modules/system/tests/src/Functional/Module/DependencyTest.php \Drupal\Tests\system\Functional\Module\DependencyTest::testNoVersionInfo()
- 11.x core/modules/system/tests/src/Functional/Module/DependencyTest.php \Drupal\Tests\system\Functional\Module\DependencyTest::testNoVersionInfo()
Tests visiting admin/modules when a module outside of core has no version.
File
-
core/
modules/ system/ tests/ src/ Functional/ Module/ DependencyTest.php, line 102
Class
- DependencyTest
- Enable module without dependency enabled.
Namespace
Drupal\Tests\system\Functional\ModuleCode
public function testNoVersionInfo() {
// Create a module for testing. We set core_version_requirement to '*' for
// the test so that it does not need to be updated between major versions.
$info = [
'type' => 'module',
'core_version_requirement' => '*',
'name' => 'System no module version dependency test',
];
$path = $this->siteDirectory . '/modules/system_no_module_version_dependency_test';
mkdir($path, 0777, TRUE);
file_put_contents("{$path}/system_no_module_version_dependency_test.info.yml", Yaml::encode($info));
// Include a version in the dependency definition, to test the 'incompatible
// with version' message when no version is given in the required module.
$info = [
'type' => 'module',
'core_version_requirement' => '*',
'name' => 'System no module version test',
'dependencies' => [
'system_no_module_version_dependency_test(>1.x)',
],
];
$path = $this->siteDirectory . '/modules/system_no_module_version_test';
mkdir($path, 0777, TRUE);
file_put_contents("{$path}/system_no_module_version_test.info.yml", Yaml::encode($info));
// Ensure that the module list page is displayed without errors.
$this->drupalGet('admin/modules');
$this->assertSession()
->pageTextContains('System no module version test');
$this->assertSession()
->pageTextContains('System no module version dependency test (>1.x) (incompatible with version');
$this->assertSession()
->fieldEnabled('modules[system_no_module_version_dependency_test][enable]');
$this->assertSession()
->fieldDisabled('modules[system_no_module_version_test][enable]');
// Remove the version requirement from the the dependency definition
$info = [
'type' => 'module',
'core_version_requirement' => '*',
'name' => 'System no module version test',
'dependencies' => [
'system_no_module_version_dependency_test',
],
];
$path = $this->siteDirectory . '/modules/system_no_module_version_test';
file_put_contents("{$path}/system_no_module_version_test.info.yml", Yaml::encode($info));
$this->drupalGet('admin/modules');
$this->assertSession()
->pageTextContains('System no module version dependency test');
$this->assertSession()
->pageTextContains('System no module version test');
// Ensure the modules can actually be installed.
$edit['modules[system_no_module_version_test][enable]'] = 'system_no_module_version_test';
$edit['modules[system_no_module_version_dependency_test][enable]'] = 'system_no_module_version_dependency_test';
$this->drupalGet('admin/modules');
$this->submitForm($edit, 'Install');
$this->assertSession()
->pageTextContains('2 modules have been enabled: System no module version dependency test, System no module version test.');
// Ensure status report is working.
$this->drupalLogin($this->createUser([
'administer site configuration',
]));
$this->drupalGet('admin/reports/status');
$this->assertSession()
->statusCodeEquals(200);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.