diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2008-12-18 00:42:55 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2008-12-18 00:42:55 +0000 |
commit | a7d66871bd3f9c4709e2e30ad16efc8199ad3455 (patch) | |
tree | 942acbb085f98f3ec6623849dd51de2405bdbf10 /modules/simpletest/drupal_web_test_case.php | |
parent | 574a2e47eea1bc8e2ea13240e407a32e4b728560 (diff) | |
download | brdo-a7d66871bd3f9c4709e2e30ad16efc8199ad3455.tar.gz brdo-a7d66871bd3f9c4709e2e30ad16efc8199ad3455.tar.bz2 |
#283246 by Damien Tournoud, Dave Reid, drewish, boombatower: Store original user when prior to running tests.
Diffstat (limited to 'modules/simpletest/drupal_web_test_case.php')
-rw-r--r-- | modules/simpletest/drupal_web_test_case.php | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php index 43795c988..60382b6bf 100644 --- a/modules/simpletest/drupal_web_test_case.php +++ b/modules/simpletest/drupal_web_test_case.php @@ -92,6 +92,13 @@ class DrupalWebTestCase { protected $originalFileDirectory = NULL; /** + * The original user, before it was changed to a clean uid = 1 for testing purposes. + * + * @var object + */ + protected $originalUser = NULL; + + /** * Current results of this test case. * * @var Array @@ -779,7 +786,7 @@ class DrupalWebTestCase { * List of modules to enable for the duration of the test. */ protected function setUp() { - global $db_prefix; + global $db_prefix, $user; // Store necessary current values before switching to prefixed database. $this->originalPrefix = $db_prefix; @@ -814,6 +821,11 @@ class DrupalWebTestCase { $this->refreshVariables(); $this->checkPermissions(array(), TRUE); + // Log in with a clean $user. + $this->originalUser = $user; + drupal_save_session(FALSE); + $user = user_load(array('uid' => 1)); + // Restore necessary variables. variable_set('install_profile', 'default'); variable_set('install_task', 'profile-finished'); @@ -860,7 +872,7 @@ class DrupalWebTestCase { * and reset the database prefix. */ protected function tearDown() { - global $db_prefix; + global $db_prefix, $user; if (preg_match('/simpletest\d+/', $db_prefix)) { // Delete temporary files directory and reset files directory path. simpletest_clean_temporary_directory(file_directory_path()); @@ -876,6 +888,10 @@ class DrupalWebTestCase { // Return the database prefix to the original. $db_prefix = $this->originalPrefix; + // Return the user to the original one. + $user = $this->originalUser; + drupal_save_session(TRUE); + // Ensure that the internal logged in variable is reset. $this->isLoggedIn = FALSE; |