From b87b7c2d01f1200d65311fce4b249cbd27f0bab9 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Thu, 5 Jun 2008 21:55:45 +0000 Subject: [PATCH] - Patch #265040 by flobruit: Remove drupalModuleEnable() from simpletest. --- includes/xmlrpc.test | 6 +- modules/profile/profile.test | 3 +- modules/search/search.test | 7 +-- modules/simpletest/drupal_web_test_case.php | 70 +++------------------ modules/tracker/tracker.test | 5 +- 5 files changed, 16 insertions(+), 75 deletions(-) diff --git a/includes/xmlrpc.test b/includes/xmlrpc.test index 032faf2260b..df5ed66d066 100644 --- a/includes/xmlrpc.test +++ b/includes/xmlrpc.test @@ -12,9 +12,13 @@ class XMLRPCValidator1Test extends DrupalWebTestCase { 'group' => t('XML-RPC') ); } + + function setUp() { + parent::setUp('simpletest_xmlrpc'); + } function test_run_all_tests() { - if (!$this->drupalModuleEnable('simpletest_xmlrpc')) { + if (!module_exists('simpletest_xmlrpc')) { return FALSE; } $xml_url = url(NULL, array('absolute' => TRUE)) . 'xmlrpc.php'; diff --git a/modules/profile/profile.test b/modules/profile/profile.test index d594c345c3d..8665457f7fb 100644 --- a/modules/profile/profile.test +++ b/modules/profile/profile.test @@ -9,9 +9,8 @@ class ProfileTestCase extends DrupalWebTestCase { protected $normal_user; function setUp() { - parent::setUp(); + parent::setUp('profile'); variable_set('user_register', 1); - $this->drupalModuleEnable('profile'); $this->admin_user = $this->drupalCreateUser(array('administer users', 'access user profiles')); diff --git a/modules/search/search.test b/modules/search/search.test index e06be293b5f..647e20cd9ea 100644 --- a/modules/search/search.test +++ b/modules/search/search.test @@ -212,15 +212,10 @@ class SearchRankingTestCase extends DrupalWebTestCase { * Implementation setUp(). */ function setUp() { - parent::setUp('search'); + parent::setUp('search', 'statistics', 'comment'); } function testRankings() { - // Enable modules that are tested. - $this->drupalModuleEnable('search'); - $this->drupalModuleEnable('statistics'); - $this->drupalModuleEnable('comment'); - // Login with sufficient privileges. $this->drupalLogin($this->drupalCreateUser(array('post comments without approval', 'create page content'))); diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php index 438017355a8..543416a779a 100644 --- a/modules/simpletest/drupal_web_test_case.php +++ b/modules/simpletest/drupal_web_test_case.php @@ -10,7 +10,6 @@ class DrupalWebTestCase extends UnitTestCase { protected $plain_text; protected $ch; protected $elements; - protected $_modules = array(); // We do not reuse the cookies in further runs, so we do not need a file // but we still need cookie handling, so we set the jar to NULL protected $cookie_file = NULL; @@ -182,57 +181,6 @@ class DrupalWebTestCase extends UnitTestCase { return $prefix; } - /** - * Enables a drupal module in the test database. Any module that is not - * part of the required core modules needs to be enabled in order to use - * it in a test. - * - * @param string $name Name of the module to enable. - * @return boolean Success. - */ - function drupalModuleEnable($name) { - if (module_exists($name)) { - return $this->pass(t('@name module already enabled', array('@name' => $name)), t('Module')); - } - $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(); - - return $this->assertTrue(module_exists($name), t('@name enabled.', array('@name' => $name)), t('Module')); - } - - /** - * Disables a drupal module in the test database. - * - * @param string $name Name of the module. - * @return boolean Success. - * @see drupalModuleEnable() - */ - function drupalModuleDisable($name) { - if (!module_exists($name)) { - return $this->pass(t('@name module already disabled', array('@name' => $name)), t('Module')); - } - 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(); - - return $this->assertTrue(!module_exists($name), t('@name disabled.', array('@name' => $name)), t('Module')); - } - /** * Create a user with a given set of permissions. The permissions correspond to the * names given on the privileges page. @@ -348,12 +296,14 @@ class DrupalWebTestCase extends UnitTestCase { } /** - * Generates a random database prefix and runs the install scripts on the prefixed database. - * After installation many caches are flushed and the internal browser is setup so that the page - * requests will run on the new prefix. A temporary files directory is created with the same name - * as the database prefix. + * Generates a random database prefix, runs the install scripts on the + * prefixed database and enable the specified modules. After installation + * many caches are flushed and the internal browser is setup so that the + * page requests will run on the new prefix. A temporary files directory + * is created with the same name as the database prefix. * - * @param ... List modules to enable. + * @param ... + * List of modules to enable for the duration of the test. */ function setUp() { global $db_prefix; @@ -372,11 +322,7 @@ class DrupalWebTestCase extends UnitTestCase { $modules = array_unique(array_merge(drupal_verify_profile('default', 'en'), $args)); drupal_install_modules($modules); - // Store the list of modules for use in subsequent drupalModuleEnable calls. - $this->_modules = drupal_map_assoc($modules); - $this->_modules['system'] = 'system'; - - // Run defualt profile tasks. + // Run default profile tasks. $task = 'profile'; default_profile_tasks($task, ''); diff --git a/modules/tracker/tracker.test b/modules/tracker/tracker.test index 85fc6dba5d6..5f6f65dadd8 100644 --- a/modules/tracker/tracker.test +++ b/modules/tracker/tracker.test @@ -21,10 +21,7 @@ class TrackerTest extends DrupalWebTestCase { * Implementation of setUp(). */ function setUp() { - parent::setUp(); - - $this->drupalModuleEnable('comment'); - $this->drupalModuleEnable('tracker'); + parent::setUp('comment', 'tracker'); $permissions = array('access comments', 'post comments', 'post comments without approval'); $this->user = $this->drupalCreateUser($permissions);