diff --git a/docroot/modules/simpletest/drupal_web_test_case.php b/docroot/modules/simpletest/drupal_web_test_case.php index 7c2cc60..fb3dd97 100644 --- a/docroot/modules/simpletest/drupal_web_test_case.php +++ b/docroot/modules/simpletest/drupal_web_test_case.php @@ -1448,7 +1448,7 @@ class DrupalWebTestCase extends DrupalTestCase { * The cache key to use, by default only based on profile. */ protected function getCacheKey() { - return '1cache_' . $this->profile; + return isset($this->cacheKey) ? '1cache_' . $this->cacheKey : '1cache_' . $this->profile; } /** @@ -1610,7 +1610,14 @@ class DrupalWebTestCase extends DrupalTestCase { // profile's hook_install() and other hook implementations are never invoked. $conf['install_profile'] = $this->profile; - if ($this->useCache()) { + $this->cacheKey = $this->profile . '_' . hash('crc32b', serialize(func_get_args())); + $use_cache_advanced = $this->useCache(); + if (!$use_cache_advanced) { + $this->cacheKey = $this->profile; + $use_cache = $this->useCache(); + } + + if ($use_cache_advanced || $use_cache) { // Reset path variables. variable_set('file_public_path', $this->public_files_directory); variable_set('file_private_path', $this->private_files_directory); @@ -1641,37 +1648,43 @@ class DrupalWebTestCase extends DrupalTestCase { // Install the modules specified by the testing profile. module_enable($profile_details['dependencies'], FALSE); + + $this->cacheKey = $this->profile; $this->storeCache(); } + if (!$use_cache_advanced) { + // 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 + // $modules as a single array argument. + $modules = func_get_args(); + if (isset($modules[0]) && is_array($modules[0])) { + $modules = $modules[0]; + } + if ($modules) { + $success = module_enable($modules, TRUE); + $this->assertTrue($success, t('Enabled modules: %modules', array('%modules' => implode(', ', $modules)))); + } - // 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 - // $modules as a single array argument. - $modules = func_get_args(); - if (isset($modules[0]) && is_array($modules[0])) { - $modules = $modules[0]; - } - if ($modules) { - $success = module_enable($modules, TRUE); - $this->assertTrue($success, t('Enabled modules: %modules', array('%modules' => implode(', ', $modules)))); - } + // Run the profile tasks. + $install_profile_module_exists = db_query("SELECT 1 FROM {system} WHERE type = 'module' AND name = :name", array( + ':name' => $this->profile, + ))->fetchField(); + if ($install_profile_module_exists) { + module_enable(array($this->profile), FALSE); + } - // Run the profile tasks. - $install_profile_module_exists = db_query("SELECT 1 FROM {system} WHERE type = 'module' AND name = :name", array( - ':name' => $this->profile, - ))->fetchField(); - if ($install_profile_module_exists) { - module_enable(array($this->profile), FALSE); - } + // Reset/rebuild all data structures after enabling the modules. + $this->resetAll(); - // Reset/rebuild all data structures after enabling the modules. - $this->resetAll(); + // Run cron once in that environment, as install.php does at the end of + // the installation process. + drupal_cron_run(); - // Run cron once in that environment, as install.php does at the end of - // the installation process. - drupal_cron_run(); + $this->cacheKey = $this->profile . '_' . hash('crc32b', serialize(func_get_args())); + $this->storeCache(); + } // 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.