Problem

  • Global variables of the parent site/test runner are leaking into each test.
  • Global variables set/changed by one test case are leaking into subsequent test cases.
  • TestBase and WebTestBase back up and restore countless of individual global variables to combat particular environment leaking problems that have been identified in the past.

Goal

  • Prevent any global variable from leaking into any test.

Proposed solution

  1. Back up and restore all global variables before and after test execution.
  2. Empty out all global variables directly before executing a test's setUp().
  3. Adjust Drupal bootstrap to allow to re-bootstrap the early environment setter functions drupal_environment_initialize() and drupal_settings_initialize().

Notes

Related issues

Comments

lyricnz’s picture

StatusFileSize
new4.11 KB

Reroll, post #1774388: Unit Tests Remastered™.

Is there any reason why the theme (originalTheme,originalThemeKey) are still handled separately?

Crell’s picture

Status: Active » Needs review
sun’s picture

Since we currently experience many random test failures, I've created a separate issue to quick-fix global $conf:

#2217087: global $conf leaks into all tests

sun’s picture

Status: Needs review » Closed (won't fix)
Related issues: +#2304461: KernelTestBaseTNG™

Implicitly fixed by using PHPUnit. PHPUnit properly handles this (and much more).