You are here

function DrupalTestCase::drupalModuleEnable in SimpleTest 5

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

Enables a drupal module

Parameters

string $name name of the module:

Return value

boolean success

11 calls to DrupalTestCase::drupalModuleEnable()
ImageModuleTest::testImageNode in tests/image_module.test
ProfileModuleTest2::testProfileOtherFields in tests/profile_module.test
ProfileModuleTestCheckbox::testProfileCheckbox in tests/profile_module.test
ProfileModuleTestDate::testProfileSingle in tests/profile_module.test
ProfileModuleTestFreelist::testProfileSingle in tests/profile_module.test

... See full list

File

./drupal_test_case.php, line 173

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 drupalModuleEnable($name) {
  if (module_exists($name)) {
    $this
      ->pass(" [module] {$name} already enabled");
    return TRUE;
  }
  include_once './includes/install.inc';
  module_rebuild_cache();

  // Rebuild the module cache
  if (drupal_get_installed_schema_version($name, TRUE) == SCHEMA_UNINSTALLED) {
    drupal_install_modules(array(
      $name,
    ));
  }
  else {
    $try = module_enable(array(
      $name,
    ));
  }
  if (module_exists($name)) {
    if (!isset($this->_cleanupModules[$name])) {
      $this->_cleanupModules[$name] = 0;
    }
    $this
      ->pass(" [module] {$name} enabled");
    return TRUE;
  }
  else {
    $this
      ->fail(" [module] {$name} could not be enbled, probably file not exists");
    return FALSE;
  }
}