Commit fc3079f9 authored by Drew Webber's avatar Drew Webber
Browse files

Issue #2871459 by mcdruid, Stevel, MustangGB, poker10, brad.bulger: Simpletest...

Issue #2871459 by mcdruid, Stevel, MustangGB, poker10, brad.bulger: Simpletest does not reset the $theme* globals
parent 552b627d
Loading
Loading
Loading
Loading
+28 −2
Original line number Diff line number Diff line
@@ -75,6 +75,21 @@ abstract class DrupalTestCase {
   */
  protected $originalLanguageDefault;

  /**
   * The original theme.
   */
   protected $originalTheme;

   /**
    * The original theme key.
    */
   protected $originalThemeKey;

   /**
    * The original theme path.
    */
   protected $originalThemePath;

  /**
   * Current results of this test case.
   *
@@ -1451,7 +1466,7 @@ protected function changeDatabasePrefix() {
   * @see DrupalWebTestCase::tearDown()
   */
  protected function prepareEnvironment() {
    global $user, $language, $language_url, $conf;
    global $user, $language, $language_url, $conf, $theme, $theme_key, $theme_path;

    // Store necessary current values before switching to prefixed database.
    $this->originalLanguage = $language;
@@ -1468,6 +1483,12 @@ protected function prepareEnvironment() {
    // The following array/object conversion is copied from language_default().
    $language_url = $language = (object) array('language' => 'en', 'name' => 'English', 'native' => 'English', 'direction' => 0, 'enabled' => 1, 'plurals' => 0, 'formula' => '', 'domain' => '', 'prefix' => '', 'weight' => 0, 'javascript' => '');

    // Reset the theme globals.
    $this->originalTheme = $theme;
    $this->originalThemeKey = $theme_key;
    $this->originalThemePath = $theme_path;
    $theme = $theme_key = $theme_path = NULL;

    // 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
    // from both environments and the testing environment will try to call the
@@ -1919,7 +1940,7 @@ protected function refreshVariables() {
   * and reset the database prefix.
   */
  protected function tearDown() {
    global $user, $language, $language_url;
    global $user, $language, $language_url, $theme, $theme_key, $theme_path;

    // In case a fatal error occurred that was not in the test process read the
    // log to pick up any fatal errors.
@@ -1992,6 +2013,11 @@ protected function tearDown() {
      $GLOBALS['conf']['language_default'] = $this->originalLanguageDefault;
    }

    // Reset theme.
    $theme = $this->originalTheme;
    $theme_key = $this->originalThemeKey;
    $theme_path = $this->originalThemePath;

    // Close the CURL handler and reset the cookies array so test classes
    // containing multiple tests are not polluted.
    $this->curlClose();