You are here

function SimplifiedModulesTestCase::testEnableDisableHiddenSubModule in Simplified Modules 7

Test enabling and disabling a hidden submodules in various combinations.

File

./simplified_modules.test, line 26

Class

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

Code

function testEnableDisableHiddenSubModule() {

  // Trigger the submodules we want to be hidden for this test.
  variable_set('simplified_modules_test_submodules', TRUE);

  // Make sure that the two modules which the submodule depends on are both
  // disabled at the beginning. The submodule should also start off as
  // disabled.
  $this
    ->setModuleStatus(array(
    'forum' => FALSE,
    'poll' => FALSE,
  ));
  $this
    ->assertFalse(module_exists('simplified_modules_test_submodule'), t('The submodule starts off as disabled.'));

  // Enable both modules at the same time. The submodule should automatically
  // be enabled.
  $this
    ->setModuleStatus(array(
    'forum' => TRUE,
    'poll' => TRUE,
  ));
  $this
    ->assertTrue(module_exists('simplified_modules_test_submodule'), t('The submodule was automatically enabled.'));

  // Disable one of the them. The submodule should be automatically disabled.
  $this
    ->setModuleStatus(array(
    'forum' => FALSE,
  ));
  $this
    ->assertFalse(module_exists('simplified_modules_test_submodule'), t('The submodule was automatically disabled.'));

  // Disable the other while enabling the first. The submodule should remain
  // disabled.
  $this
    ->setModuleStatus(array(
    'forum' => TRUE,
    'poll' => FALSE,
  ));
  $this
    ->assertFalse(module_exists('simplified_modules_test_submodule'), t('The submodule remained disabled since its dependencies were not both enabled.'));

  // Enabling the second module should now result in the submodule being
  // enabled again.
  $this
    ->setModuleStatus(array(
    'poll' => TRUE,
  ));
  $this
    ->assertTrue(module_exists('simplified_modules_test_submodule'), t('The submodule was automatically enabled.'));
}