diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php index aed66fa..94a9fa5 100644 --- a/modules/simpletest/drupal_web_test_case.php +++ b/modules/simpletest/drupal_web_test_case.php @@ -1464,6 +1623,42 @@ class DrupalWebTestCase extends DrupalTestCase { // profile's hook_install() and other hook implementations are never invoked. $conf['install_profile'] = $this->profile; + $use_cache = FALSE; + $use_modules_cache = FALSE; + + if ($this->cacheModules) { + $modules = func_get_args(); + // Modules can be either one parameter or multiple. + if (isset($modules[0]) && is_array($modules[0])) { + $modules = $modules[0]; + } + $modules = array_unique($modules); + sort($modules); + + $modules_cache_key_suffix = '_' . hash('crc32b', serialize($modules)); + $use_modules_cache = $this->useCache($modules_cache_key_suffix); + } + + if (!$use_modules_cache && $this->cache) { + $use_cache = $this->useCache(); + } + + if ($use_modules_cache || $use_cache) { + // Reset path variables. + variable_set('file_public_path', $this->public_files_directory); + variable_set('file_private_path', $this->private_files_directory); + variable_set('file_temporary_path', $this->temp_files_directory); + $this->refreshVariables(); + + // Load all enabled modules + module_load_all(); + + $this->assertTrue(TRUE, t('Using cache: @cache (@key)', array( + '@cache' => ($use_modules_cache ? 'Modules Cache' : 'Normal Cache'), + '@key' => $this->getCacheKey($use_modules_cache ? $modules_cache_key_suffix : ''), + ))); + } + else { // Perform the actual Drupal installation. include_once DRUPAL_ROOT . '/includes/install.inc'; drupal_install_system(); @@ -1488,6 +1683,12 @@ class DrupalWebTestCase extends DrupalTestCase { // Install the modules specified by the testing profile. module_enable($profile_details['dependencies'], FALSE); + if ($this->cache) { + $this->storeCache(); + } + } + + if (!$use_modules_cache) { // Install modules needed for this test. This could have been passed in as // either a single array argument or a variable number of string arguments. // @todo Remove this compatibility layer in Drupal 8, and only accept @@ -1516,6 +1717,15 @@ class DrupalWebTestCase extends DrupalTestCase { // the installation process. drupal_cron_run(); + if ($this->cacheModules) { + $this->storeCache($modules_cache_key_suffix); + } + } + else { + // Reset/rebuild all data structures after enabling the modules. + $this->resetAll(); + } + // Ensure that the session is not written to the new environment and replace // the global $user session with uid 1 from the new test site. drupal_save_session(FALSE);