You are here

function DrupalTestCase::drupalModuleDisable in SimpleTest 5

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

Disables a drupal module

Parameters

string $name name of the module:

Return value

boolean success

2 calls to DrupalTestCase::drupalModuleDisable()
TaxonomyTestNodeApi::testTaxonomyNode in tests/taxonomy.module.test
UserRegistrationTest::testUserRegistration in tests/user_registration_test.test

File

./drupal_test_case.php, line 206

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;
  }

  /* Update table */
  db_query("UPDATE {system} SET status = 0 WHERE name = '%s' AND type = 'module'", $name);
  if (db_affected_rows()) {

    /* Make sure not overwriting when double switching */
    if (!isset($this->_cleanupModules[$name])) {
      $this->_cleanupModules[$name] = 1;
    }

    /* refresh module_list */
    module_list(TRUE, FALSE);
    $this
      ->pass(" [module] {$name} disabled");
    return TRUE;
  }
  $this
    ->fail(" [module] {$name} could not be disabled for unknown reason");
  return FALSE;
}