You are here

function DrupalTestCase::drupalModuleEnable in SimpleTest 6

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

Enables a drupal module

Parameters

string $name name of the module:

Return value

boolean success

25 calls to DrupalTestCase::drupalModuleEnable()
ActionsContentTest::testActionsContent in tests/content_actions.test
Various tests, all in one function to assure they happen in the right order.
BlogAPIModuleTestCase::setUp in tests/blogapi_module.test
BookModuleTestCase::setUp in tests/book_module.test
CommentModuleTestCase::setUp in tests/comment_module.test
DrupalForumTestCase::setUp in tests/forum_module.test

... See full list

File

./drupal_test_case.php, line 273

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;
  }
  $this
    ->checkOriginalModules();
  if (array_search($name, $this->_modules) === FALSE) {
    $this->_modules[$name] = $name;
    $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();
  }
}