diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index 0b861c4..d273df7 100644
--- a/core/includes/bootstrap.inc
+++ b/core/includes/bootstrap.inc
@@ -2136,8 +2136,9 @@ function drupal_anonymous_user() {
* The most recently completed phase.
*/
function drupal_bootstrap($phase = NULL, $new_phase = TRUE) {
- // Not drupal_static(), because does not depend on any run-time information.
- static $phases = array(
+ // drupal_static(), since tests need to be able to re-bootstrap Drupal from an
+ // almost clean slate.
+ $phases = &drupal_static('bootstrap:phases', array(
DRUPAL_BOOTSTRAP_CONFIGURATION,
DRUPAL_BOOTSTRAP_PAGE_CACHE,
DRUPAL_BOOTSTRAP_DATABASE,
@@ -2146,13 +2147,9 @@ function drupal_bootstrap($phase = NULL, $new_phase = TRUE) {
DRUPAL_BOOTSTRAP_PAGE_HEADER,
DRUPAL_BOOTSTRAP_LANGUAGE,
DRUPAL_BOOTSTRAP_FULL,
- );
- // Not drupal_static(), because the only legitimate API to control this is to
- // call drupal_bootstrap() with a new phase parameter.
- static $final_phase;
- // Not drupal_static(), because it's impossible to roll back to an earlier
- // bootstrap state.
- static $stored_phase = -1;
+ ));
+ $final_phase = &drupal_static('bootstrap:final');
+ $stored_phase = &drupal_static('bootstrap:last', -1);
// When not recursing, store the phase name so it's not forgotten while
// recursing.
diff --git a/core/includes/common.inc b/core/includes/common.inc
index 9da67ac..9144675 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -5046,12 +5046,6 @@ function drupal_valid_token($token, $value = '', $skip_anonymous = FALSE) {
}
function _drupal_bootstrap_full() {
- static $called = FALSE;
-
- if ($called) {
- return;
- }
- $called = TRUE;
require_once DRUPAL_ROOT . '/' . variable_get('path_inc', 'core/includes/path.inc');
require_once DRUPAL_ROOT . '/core/includes/theme.inc';
require_once DRUPAL_ROOT . '/core/includes/pager.inc';
diff --git a/core/includes/module.inc b/core/includes/module.inc
index 221ad60..0dee0ea 100644
--- a/core/includes/module.inc
+++ b/core/includes/module.inc
@@ -17,7 +17,7 @@
* have been loaded.
*/
function module_load_all($bootstrap = FALSE) {
- static $has_run = FALSE;
+ $has_run = &drupal_static(__FUNCTION__, FALSE);
if (isset($bootstrap)) {
foreach (module_list(TRUE, $bootstrap) as $module) {
@@ -64,7 +64,8 @@ function module_load_all($bootstrap = FALSE) {
* the list.
*/
function module_list($refresh = FALSE, $bootstrap_refresh = FALSE, $sort = FALSE, $fixed_list = NULL) {
- static $list = array(), $sorted_list;
+ $list = &drupal_static(__FUNCTION__, array());
+ $sorted_list = &drupal_static(__FUNCTION__ . ':sorted');
if (empty($list) || $refresh || $fixed_list) {
$list = array();
diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index 5304d25..cb7fdaf 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -252,7 +252,8 @@ function _drupal_theme_initialize($theme, $base_theme = array(), $registry_callb
* class.
*/
function theme_get_registry($complete = TRUE) {
- static $theme_registry = array();
+ // @todo Theme is not reset after test bootstrap yet. Why?
+ $theme_registry = &drupal_static(__FUNCTION__, array());
$key = (int) $complete;
if (!isset($theme_registry[$key])) {
@@ -275,7 +276,8 @@ function theme_get_registry($complete = TRUE) {
* The arguments to pass to the function.
*/
function _theme_registry_callback($callback = NULL, array $arguments = array()) {
- static $stored;
+ // @todo Theme is not reset after test bootstrap yet. Why?
+ $stored = &drupal_static(__FUNCTION__);
if (isset($callback)) {
$stored = array($callback, $arguments);
}
diff --git a/core/modules/simpletest/drupal_web_test_case.php b/core/modules/simpletest/drupal_web_test_case.php
index a5fb606..7b9db5f 100644
--- a/core/modules/simpletest/drupal_web_test_case.php
+++ b/core/modules/simpletest/drupal_web_test_case.php
@@ -1293,10 +1293,6 @@ class DrupalWebTestCase extends DrupalTestCase {
->condition('test_id', $this->testId)
->execute();
- // Reset all statics and variables to perform tests in a clean environment.
- $conf = array();
- drupal_static_reset();
-
// Clone the current connection and replace the current prefix.
$connection_info = Database::getConnectionInfo('default');
Database::renameConnection('default', 'simpletest_original_default');
@@ -1355,6 +1351,10 @@ class DrupalWebTestCase extends DrupalTestCase {
$test_info['test_run_id'] = $this->databasePrefix;
$test_info['in_child_site'] = FALSE;
+ // Reset all statics and variables to perform tests in a clean environment.
+ $conf = array();
+ drupal_static_reset();
+
// Preset the 'install_profile' system variable, so the first call into
// system_rebuild_module_data() (in drupal_install_system()) will register
// the test's profile as a module. Without this, the installation profile of
@@ -1363,6 +1363,15 @@ class DrupalWebTestCase extends DrupalTestCase {
$conf['install_profile'] = $this->profile;
include_once DRUPAL_ROOT . '/core/includes/install.inc';
+
+ $module_list['system']['filename'] = 'core/modules/system/system.module';
+ $module_list['entity']['filename'] = 'core/modules/entity/entity.module';
+ $module_list['user']['filename'] = 'core/modules/user/user.module';
+ module_list(TRUE, FALSE, FALSE, $module_list);
+
+ // @todo Theme is not reset after test bootstrap yet. Why?
+ unset($GLOBALS['theme'], $GLOBALS['theme_key'], $GLOBALS['theme_info'], $GLOBALS['base_theme_info'], $GLOBALS['theme_path'], $GLOBALS['theme_engine']);
+
drupal_install_system();
$this->preloadRegistry();
@@ -1389,7 +1398,8 @@ class DrupalWebTestCase extends DrupalTestCase {
}
if ($modules) {
$success = module_enable($modules, TRUE);
- $this->assertTrue($success, t('Enabled modules: %modules', array('%modules' => implode(', ', $modules))));
+ // @todo t() calls theme() for some reason; and that's too early, modules aren't loaded yet.
+ $this->assertTrue($success, strtr('Enabled modules: %modules', array('%modules' => implode(', ', $modules))));
}
// Run the profile tasks.
@@ -1400,8 +1410,8 @@ class DrupalWebTestCase extends DrupalTestCase {
module_enable(array($this->profile), FALSE);
}
- // Reset/rebuild all data structures after enabling the modules.
- $this->resetAll();
+ // Bootstrap into test environment.
+ drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
// Run cron once in that environment, as install.php does at the end of
// the installation process.
diff --git a/core/modules/simpletest/tests/file.test b/core/modules/simpletest/tests/file.test
index 7496902..3a73c08 100644
--- a/core/modules/simpletest/tests/file.test
+++ b/core/modules/simpletest/tests/file.test
@@ -47,6 +47,8 @@ function file_test_file_scan_callback_reset() {
* assertions and helper functions.
*/
class FileTestCase extends DrupalWebTestCase {
+ protected $profile = 'testing';
+
/**
* Check that two files have the same values for all fields other than the
* timestamp.