ModuleDependencyTestCase::testMissingModules

7 system.test ModuleDependencyTestCase::testMissingModules()
8 system.test ModuleDependencyTestCase::testMissingModules()

Attempt to enable a module with a missing dependency.

File

modules/system/system.test, line 421
Tests for system.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'))), t('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, t('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')), t('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);
}
Login or register to post comments