diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php index b67c478..05c8f53 100644 --- a/modules/simpletest/drupal_web_test_case.php +++ b/modules/simpletest/drupal_web_test_case.php @@ -1364,10 +1364,13 @@ class DrupalWebTestCase extends DrupalTestCase { * @see DrupalWebTestCase::tearDown() */ protected function prepareEnvironment() { - global $user, $language, $conf; + global $user, $conf; // Store necessary current values before switching to prefixed database. - $this->originalLanguage = $language; + $this->originalLanguages = array(); + foreach (drupal_language_types() as $language_type => $_) { + $this->originalLanguages[$language_type] = $GLOBALS[$language_type]; + } $this->originalLanguageDefault = variable_get('language_default'); $this->originalFileDirectory = variable_get('file_public_path', conf_path() . '/files'); $this->originalProfile = drupal_get_profile(); @@ -1377,7 +1380,9 @@ class DrupalWebTestCase extends DrupalTestCase { // Set to English to prevent exceptions from utf8_truncate() from t() // during install if the current language is not 'en'. // The following array/object conversion is copied from language_default(). - $language = (object) array('language' => 'en', 'name' => 'English', 'native' => 'English', 'direction' => 0, 'enabled' => 1, 'plurals' => 0, 'formula' => '', 'domain' => '', 'prefix' => '', 'weight' => 0, 'javascript' => ''); + foreach (drupal_language_types() as $language_type => $_) { + $GLOBALS[$language_type] = (object) array('language' => 'en', 'name' => 'English', 'native' => 'English', 'direction' => 0, 'enabled' => 1, 'plurals' => 0, 'formula' => '', 'domain' => '', 'prefix' => '', 'weight' => 0, 'javascript' => ''); + } // Save and clean the shutdown callbacks array because it is static cached // and will be changed by the test run. Otherwise it will contain callbacks @@ -1626,7 +1631,7 @@ class DrupalWebTestCase extends DrupalTestCase { * and reset the database prefix. */ protected function tearDown() { - global $user, $language; + global $user; // In case a fatal error occurred that was not in the test process read the // log to pick up any fatal errors. @@ -1689,8 +1694,10 @@ class DrupalWebTestCase extends DrupalTestCase { // Reset public files directory. $GLOBALS['conf']['file_public_path'] = $this->originalFileDirectory; - // Reset language. - $language = $this->originalLanguage; + // Reset languages. + foreach (drupal_language_types() as $language_type => $_) { + $GLOBALS[$language_type] = $this->originalLanguages[$language_type]; + } if ($this->originalLanguageDefault) { $GLOBALS['conf']['language_default'] = $this->originalLanguageDefault; }