Index: modules/simpletest/drupal_web_test_case.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v
retrieving revision 1.25
diff -u -r1.25 drupal_web_test_case.php
--- modules/simpletest/drupal_web_test_case.php	5 Jul 2008 07:19:31 -0000	1.25
+++ modules/simpletest/drupal_web_test_case.php	16 Jul 2008 07:10:07 -0000
@@ -18,6 +18,7 @@
   protected $curl_options = array();
   protected $db_prefix_original;
   protected $original_file_directory;
+  protected $original_user;
 
   var $_results = array('#pass' => 0, '#fail' => 0, '#exception' => 0);
   var $_assertions = array();
@@ -649,6 +650,11 @@
     $this->refreshVariables();
     $this->checkPermissions(array(), TRUE);
 
+    // Log in with a clean $user
+    $this->original_user = $GLOBALS['user'];
+    session_save_session(FALSE);
+    $GLOBALS['user'] = user_load(array('uid' => 1));
+
     // Restore necessary variables.
     variable_set('install_profile', 'default');
     variable_set('install_task', 'profile-finished');
@@ -699,6 +705,10 @@
       // Return the database prefix to the original.
       $db_prefix = $this->db_prefix_original;
 
+      // Restore the old user object
+      $GLOBALS['user'] = $this->original_user;
+      session_save_session(TRUE);
+
       // Ensure that the internal logged in variable is reset.
       $this->_logged_in = FALSE;
 
