function DependencyTest::testEnableRequirementsFailureDependency

Same name in other branches
  1. 8.9.x core/modules/system/tests/src/Functional/Module/DependencyTest.php \Drupal\Tests\system\Functional\Module\DependencyTest::testEnableRequirementsFailureDependency()
  2. 10 core/modules/system/tests/src/Functional/Module/DependencyTest.php \Drupal\Tests\system\Functional\Module\DependencyTest::testEnableRequirementsFailureDependency()
  3. 11.x core/modules/system/tests/src/Functional/Module/DependencyTest.php \Drupal\Tests\system\Functional\Module\DependencyTest::testEnableRequirementsFailureDependency()

Tests enabling a module that depends on a module which fails hook_requirements().

File

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

Class

DependencyTest
Enable module without dependency enabled.

Namespace

Drupal\Tests\system\Functional\Module

Code

public function testEnableRequirementsFailureDependency() {
    \Drupal::service('module_installer')->install([
        'comment',
    ]);
    $this->assertModules([
        'requirements1_test',
    ], FALSE);
    $this->assertModules([
        'requirements2_test',
    ], FALSE);
    // Attempt to install both modules at the same time.
    $edit = [];
    $edit['modules[requirements1_test][enable]'] = 'requirements1_test';
    $edit['modules[requirements2_test][enable]'] = 'requirements2_test';
    $this->drupalGet('admin/modules');
    $this->submitForm($edit, 'Install');
    // Makes sure the modules were NOT installed.
    $this->assertSession()
        ->pageTextContains('Requirements 1 Test failed requirements');
    $this->assertModules([
        'requirements1_test',
    ], FALSE);
    $this->assertModules([
        'requirements2_test',
    ], FALSE);
    // Makes sure that already enabled modules the failing modules depend on
    // were not disabled.
    $this->assertModules([
        'comment',
    ], TRUE);
}

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