1 system.test ModuleDependencyTestCase::testModuleEnableOrder()

Tests that module dependencies are enabled in the correct order via the UI. Dependencies should be enabled before their dependents.

File

core/modules/system/tests/system.test, line 455
Tests for system.module.

Class

ModuleDependencyTestCase
Test module dependency functionality.

Code

function testModuleEnableOrder() {
  module_enable(array('module_test'), FALSE);
  $this->resetAll();
  $this->assertModules(array('module_test'), TRUE);
  state_set('dependency_test', 'dependency');
  // module_test creates a dependency chain: test3 depends on test2, which
  // depends on test1. The correct enable order is, test1, test2, test3.
  $expected_order = array('dependency_test1', 'dependency_test2', 'dependency_test3');

  // Enable the modules through the UI, verifying that the dependency chain
  // is correct.
  $edit = array();
  $edit['modules[Testing][dependency_test3][enable]'] = 'dependency_test3';
  $this->backdropPost('admin/modules', $edit, t('Save configuration'));
  $this->assertModules(array('dependency_test3'), FALSE);
  $this->assertText(t('You must enable the Dependency test 2, Dependency test 1 modules to install Dependency test 3.'), 'Dependency chain created.');
  $edit['modules[Testing][dependency_test2][enable]'] = 'dependency_test2';
  $edit['modules[Testing][dependency_test1][enable]'] = 'dependency_test1';
  $this->backdropPost('admin/modules', $edit, t('Save configuration'));
  $this->assertModules(array('dependency_test3', 'dependency_test2', 'dependency_test1'), TRUE);

  // Check the actual order which is saved by module_test_modules_enabled().
  $this->assertIdentical(state_get('test_module_enable_order', FALSE), $expected_order, 'Modules enabled in the correct order.');
}