private function restoreAllGlobals() { $superGlobalArrays = $this->globalStateSnapshot->superGlobalArrays(); $globalVariables = $this->globalStateSnapshot->globalVariables(); foreach (array_keys($globalVariables) as $key) { if ($key != 'GLOBALS' && !in_array($key, $superGlobalArrays) && !$this->globalStateSnapshot->blacklist()->isGlobalVariableBlacklisted($key)) { if (!isset($GLOBALS[$key])) { $GLOBALS[$key] = $globalVariables[$key]; } } } }
/** * @param Snapshot $before * @param Snapshot $after * @throws PHPUnit_Framework_RiskyTestError */ private function compareGlobalStateSnapshots(Snapshot $before, Snapshot $after) { $backupGlobals = $this->backupGlobals === null || $this->backupGlobals === true; if ($backupGlobals) { $this->compareGlobalStateSnapshotPart($before->globalVariables(), $after->globalVariables(), "--- Global variables before the test\n+++ Global variables after the test\n"); $this->compareGlobalStateSnapshotPart($before->superGlobalVariables(), $after->superGlobalVariables(), "--- Super-global variables before the test\n+++ Super-global variables after the test\n"); } if ($this->backupStaticAttributes) { $this->compareGlobalStateSnapshotPart($before->staticAttributes(), $after->staticAttributes(), "--- Static attributes before the test\n+++ Static attributes after the test\n"); } }