diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-03-07 08:10:26 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-03-07 08:10:26 +0000 |
commit | 41a0e3f0fe9f64d887d9ddb1eb8406f17b350e1f (patch) | |
tree | 32aa63c7703c835fbbf88ece21eaad6bd7b2a04e /modules/simpletest/drupal_web_test_case.php | |
parent | b04816e0fe30dab62d27bbf3ff08a15a2a14a13a (diff) | |
download | brdo-41a0e3f0fe9f64d887d9ddb1eb8406f17b350e1f.tar.gz brdo-41a0e3f0fe9f64d887d9ddb1eb8406f17b350e1f.tar.bz2 |
#721210 by andypost: Preserve shutdown handlers in SimpleTest (Allow SimpleTest module to run without Search module)
Diffstat (limited to 'modules/simpletest/drupal_web_test_case.php')
-rw-r--r-- | modules/simpletest/drupal_web_test_case.php | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php index 11c8be07b..610f43cd9 100644 --- a/modules/simpletest/drupal_web_test_case.php +++ b/modules/simpletest/drupal_web_test_case.php @@ -673,6 +673,13 @@ class DrupalWebTestCase extends DrupalTestCase { protected $originalUser = NULL; /** + * The original shutdown handlers array, before it was cleaned for testing purposes. + * + * @var array + */ + protected $originalShutdownCallbacks = array(); + + /** * HTTP authentication method */ protected $httpauth_method = CURLAUTH_BASIC; @@ -1103,6 +1110,14 @@ class DrupalWebTestCase extends DrupalTestCase { $this->originalProfile = drupal_get_profile(); $clean_url_original = variable_get('clean_url', 0); + // Save and clean shutdown callbacks array because it static cached and + // will be changed by the test run. If we don't, then it will contain + // callbacks from both environments. So testing environment will try + // to call handlers from original environment. + $callbacks = &drupal_register_shutdown_function(); + $this->originalShutdownCallbacks = $callbacks; + $callbacks = array(); + // Generate temporary prefixed database to ensure that tests have a clean starting point. $db_prefix_new = Database::getConnection()->prefixTables('{simpletest' . mt_rand(1000, 1000000) . '}'); db_update('simpletest_test_id') @@ -1256,6 +1271,11 @@ class DrupalWebTestCase extends DrupalTestCase { // Return the database prefix to the original. $db_prefix = $this->originalPrefix; + // Restore original shutdown callbacks array to prevent original + // environment of calling handlers from test run. + $callbacks = &drupal_register_shutdown_function(); + $callbacks = $this->originalShutdownCallbacks; + // Return the user to the original one. $user = $this->originalUser; drupal_save_session(TRUE); |