function DependencyTest::testMissingModules

Attempts to enable a module with a missing dependency.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Module/DependencyTest.php, line 49
Definition of Drupal\system\Tests\Module\DependencyTest.

Class

DependencyTest
Tests module dependency functionality.

Namespace

Drupal\system\Tests\Module

Code

function testMissingModules() {

  // Test that the system_dependencies_test module is marked
  // as missing a dependency.
  $this
    ->drupalGet('admin/modules');
  $this
    ->assertRaw(t('@module (<span class="admin-missing">missing</span>)', array(
    '@module' => drupal_ucfirst('_missing_dependency'),
  )), 'A module with missing dependencies is marked as such.');
  $checkbox = $this
    ->xpath('//input[@type="checkbox" and @disabled="disabled" and @name="modules[Testing][system_dependencies_test][enable]"]');
  $this
    ->assert(count($checkbox) == 1, 'Checkbox for the module is disabled.');

  // Force enable the system_dependencies_test module.
  module_enable(array(
    'system_dependencies_test',
  ), FALSE);

  // Verify that the module is forced to be disabled when submitting
  // the module page.
  $this
    ->drupalPost('admin/modules', array(), t('Save configuration'));
  $this
    ->assertText(t('The @module module is missing, so the following module will be disabled: @depends.', array(
    '@module' => '_missing_dependency',
    '@depends' => 'system_dependencies_test',
  )), 'The module missing dependencies will be disabled.');

  // Confirm.
  $this
    ->drupalPost(NULL, NULL, t('Continue'));

  // Verify that the module has been disabled.
  $this
    ->assertModules(array(
    'system_dependencies_test',
  ), FALSE);
}