You are here

function DependencyTest::testEnableRequirementsFailureDependency in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Module/DependencyTest.php \Drupal\system\Tests\Module\DependencyTest::testEnableRequirementsFailureDependency()

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

File

core/modules/system/src/Tests/Module/DependencyTest.php, line 101
Contains \Drupal\system\Tests\Module\DependencyTest.

Class

DependencyTest
Enable module without dependency enabled.

Namespace

Drupal\system\Tests\Module

Code

function testEnableRequirementsFailureDependency() {
  \Drupal::service('module_installer')
    ->install(array(
    'comment',
  ));
  $this
    ->assertModules(array(
    'requirements1_test',
  ), FALSE);
  $this
    ->assertModules(array(
    'requirements2_test',
  ), FALSE);

  // Attempt to install both modules at the same time.
  $edit = array();
  $edit['modules[Testing][requirements1_test][enable]'] = 'requirements1_test';
  $edit['modules[Testing][requirements2_test][enable]'] = 'requirements2_test';
  $this
    ->drupalPostForm('admin/modules', $edit, t('Install'));

  // Makes sure the modules were NOT installed.
  $this
    ->assertText(t('Requirements 1 Test failed requirements'), 'Modules status has been updated.');
  $this
    ->assertModules(array(
    'requirements1_test',
  ), FALSE);
  $this
    ->assertModules(array(
    'requirements2_test',
  ), FALSE);

  // Makes sure that already enabled modules the failing modules depend on
  // were not disabled.
  $this
    ->assertModules(array(
    'comment',
  ), TRUE);
}