Index: includes/module.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/module.inc,v
retrieving revision 1.182
diff -u -p -r1.182 module.inc
--- includes/module.inc	26 Feb 2010 18:31:29 -0000	1.182
+++ includes/module.inc	28 Feb 2010 02:22:54 -0000
@@ -293,12 +293,11 @@ function module_load_all_includes($type,
  *   If TRUE, dependencies will automatically be added and enabled in the
  *   correct order. This incurs a significant performance cost, so use FALSE
  *   if you know $module_list is already complete and in the correct order.
- * @param $disable_modules_installed_hook
- *   Normally just testing wants to set this to TRUE.
+ *
  * @return
  *   FALSE if one or more dependencies are missing, TRUE otherwise.
  */
-function module_enable($module_list, $enable_dependencies = TRUE, $disable_modules_installed_hook = FALSE) {
+function module_enable($module_list, $enable_dependencies = TRUE) {
   if ($enable_dependencies) {
     // Get all module data so we can find dependencies and sort.
     $module_data = system_rebuild_module_data();
@@ -392,7 +391,7 @@ function module_enable($module_list, $en
   }
 
   // If any modules were newly installed, invoke hook_modules_installed().
-  if (!$disable_modules_installed_hook && !empty($modules_installed)) {
+  if (!empty($modules_installed)) {
     module_invoke_all('modules_installed', $modules_installed);
   }
 
Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.580
diff -u -p -r1.580 theme.inc
--- includes/theme.inc	27 Feb 2010 09:24:09 -0000	1.580
+++ includes/theme.inc	28 Feb 2010 03:29:43 -0000
@@ -561,7 +561,7 @@ function _theme_build_registry($theme, $
  *   - 'base theme': The name of the base theme.
  */
 function list_themes($refresh = FALSE) {
-  static $list = array();
+  $list = &drupal_static(__FUNCTION__, array());
 
   if ($refresh) {
     $list = array();
Index: modules/simpletest/drupal_web_test_case.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v
retrieving revision 1.198
diff -u -p -r1.198 drupal_web_test_case.php
--- modules/simpletest/drupal_web_test_case.php	26 Feb 2010 17:22:39 -0000	1.198
+++ modules/simpletest/drupal_web_test_case.php	28 Feb 2010 03:29:26 -0000
@@ -547,8 +547,7 @@ abstract class DrupalTestCase {
  *
  * These tests can not access the database nor files. Calling any Drupal
  * function that needs the database will throw exceptions. These include
- * watchdog(), function_exists(), module_implements(),
- * module_invoke_all() etc.
+ * watchdog(), module_implements(), module_invoke_all() etc.
  */
 class DrupalUnitTestCase extends DrupalTestCase {
 
@@ -1139,32 +1138,29 @@ class DrupalWebTestCase extends DrupalTe
     $profile_details = install_profile_info('standard', 'en');
 
     // Install the modules specified by the default profile.
-    module_enable($profile_details['dependencies'], FALSE, TRUE);
-
-    drupal_static_reset('_node_types_build');
+    module_enable($profile_details['dependencies'], FALSE);
 
+    // Install modules needed for this test.
     if ($modules = func_get_args()) {
-      // Install modules needed for this test.
-      module_enable($modules, TRUE, TRUE);
+      module_enable($modules, TRUE);
     }
 
-    // Because the schema is static cached, we need to flush
-    // it between each run. If we don't, then it will contain
-    // stale data for the previous run's database prefix and all
-    // calls to it will fail.
-    drupal_get_schema(NULL, TRUE);
-
     // Run default profile tasks.
-    $install_state = array();
-    module_enable(array('standard'), FALSE, TRUE);
+    module_enable(array('standard'), FALSE);
 
     // Rebuild caches.
-    node_types_rebuild();
+    drupal_flush_all_caches();
+
+    // Register actions declared by any modules.
     actions_synchronize();
-    _drupal_flush_css_js();
+
+    // Reload global $conf array and permissions.
     $this->refreshVariables();
     $this->checkPermissions(array(), TRUE);
 
+    // Reset statically cached schema for new database prefix.
+    drupal_get_schema(NULL, TRUE);
+
     // Run cron once in that environment, as install.php does at the end of
     // the installation process.
     drupal_cron_run();
