You are here

function DrupalTestCase::drupalModuleDisable in SimpleTest 6

Same name and namespace in other branches
  1. 5 drupal_test_case.php \DrupalTestCase::drupalModuleDisable()

Disables a drupal module

Parameters

string $name name of the module:

Return value

boolean success

5 calls to DrupalTestCase::drupalModuleDisable()
EnableCoreModuleTest::testEnableCoreModules in tests/modules_system.test
EnableModuleWithoutDependencyTest::testEnableWithoutDependency in tests/modules_system.test
TaxonomyTestNodeApi::testTaxonomyNode in tests/taxonomy.module.test
UserDeleteTest::testUserRegistration in tests/user_module.test
UserRegistrationTest::testUserRegistration in tests/user_module.test

File

./drupal_test_case.php, line 299

Class

DrupalTestCase
Test case for typical Drupal tests. Extends WebTestCase for comfortable browser usage but also implements all UnitTestCase methods, I wish WebTestCase would do this.

Code

function drupalModuleDisable($name) {
  if (!module_exists($name)) {
    $this
      ->pass(" [module] {$name} already disabled");
    return TRUE;
  }
  $this
    ->checkOriginalModules();
  if (($key = array_search($name, $this->_modules)) !== FALSE) {
    unset($this->_modules[$key]);
    $form_state['values'] = array(
      'status' => $this->_modules,
      'op' => t('Save configuration'),
    );
    drupal_execute('system_modules', $form_state);

    //rebuilding all caches
    drupal_rebuild_theme_registry();
    node_types_rebuild();
    menu_rebuild();
    cache_clear_all('schema', 'cache');
    module_rebuild_cache();
  }
}