function DependencyTest::testModuleDependencyMessages

Tests that module dependencies install text is formatted correctly.

File

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

Class

DependencyTest
Enable module without dependency enabled.

Namespace

Drupal\Tests\system\Functional\Module

Code

public function testModuleDependencyMessages() : void {
  // Check the module install text with 1 module dependency.
  $edit = [];
  $edit['modules[file][enable]'] = 'file';
  $this->drupalGet('admin/modules');
  $this->submitForm($edit, 'Install');
  $this->assertSession()
    ->pageTextContains('You must install the following module to install File:Field');
  // Check the module install text with 2 module dependencies.
  \Drupal::service('module_installer')->install([
    'module_test',
  ], FALSE);
  \Drupal::state()->set('module_test.dependency', 'dependency');
  $edit = [];
  $edit['modules[dblog][enable]'] = 'dblog';
  $this->drupalGet('admin/modules');
  $this->submitForm($edit, 'Install');
  $this->assertSession()
    ->pageTextContains('You must install the following modules to install Database Logging:Configuration ManagerHelp');
  // Check the module install text with more than 2 module dependencies.
  $edit = [];
  $edit['modules[navigation][enable]'] = 'navigation';
  $this->drupalGet('admin/modules');
  $this->submitForm($edit, 'Install');
  $this->assertSession()
    ->pageTextContains('You must install the following modules to install Navigation:BlockFileFieldLayout BuilderLayout DiscoveryContextual Links');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.