You are here

function SimplifiedModulesTestCase::setModuleStatus in Simplified Modules 7

Helper function to enable or disable a set of modules via the UI.

Parameters

$module_info: An array whose keys are the names of modules and whose values are either TRUE (to enable the corresponding module) or FALSE (to disable it).

4 calls to SimplifiedModulesTestCase::setModuleStatus()
SimplifiedModulesTestCase::testAutoEnableHiddenDependencies in ./simplified_modules.test
Test that hidden dependencies are auto-enabled properly.
SimplifiedModulesTestCase::testCombinedSubModulesAndDependencies in ./simplified_modules.test
Test that a combined set of hidden submodules and dependencies works.
SimplifiedModulesTestCase::testDisableSimplifiedModules in ./simplified_modules.test
Test disabling Simplified Modules at the same time as the submodule.
SimplifiedModulesTestCase::testEnableDisableHiddenSubModule in ./simplified_modules.test
Test enabling and disabling a hidden submodules in various combinations.

File

./simplified_modules.test, line 159

Class

SimplifiedModulesTestCase
Tests for auto-enabling and disabling hidden submodules and dependencies.

Code

function setModuleStatus($module_info) {
  $edit = array();
  foreach ($module_info as $module => $status) {

    // Find out what group this module lives in on the modules page by
    // getting the package information from its .info file. We can't use
    // system_get_info() here since that only works for enabled modules, so
    // we have to query the database directly.
    $info = unserialize(db_query('SELECT info FROM {system} WHERE name = :name', array(
      ':name' => $module,
    ))
      ->fetchField());
    $group = $info['package'];
    $edit["modules[{$group}][{$module}][enable]"] = $status;
  }
  $this
    ->drupalPost('admin/modules', $edit, t('Save configuration'));

  // Fix a cache clearing issue in the thread running the tests.
  module_list(TRUE);
  foreach ($module_info as $module => $status) {
    if ($status) {
      $this
        ->assertTrue(module_exists($module), t('The @module module is enabled.', array(
        '@module' => $module,
      )));
    }
    else {
      $this
        ->assertFalse(module_exists($module), t('The @module module is disabled.', array(
        '@module' => $module,
      )));
    }
  }
}