You are here

public function DependencyTest::testNoVersionInfo in Drupal 10

Tests visiting admin/modules when a module outside of core has no version.

File

core/modules/system/tests/src/Functional/Module/DependencyTest.php, line 103

Class

DependencyTest
Enable module without dependency enabled.

Namespace

Drupal\Tests\system\Functional\Module

Code

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));
  $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';
  mkdir($path, 0777, TRUE);
  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);
}