Created
March 5, 2014 20:18
-
-
Save lolli42/9375718 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Composer/vendor/phpunit/phpunit/PHPUnit/Util/GlobalState.php b/Composer/vendor/phpunit/phpunit/PHPUnit/Util/GlobalState.php | |
index 2737985..baba04e 100644 | |
--- a/Composer/vendor/phpunit/phpunit/PHPUnit/Util/GlobalState.php | |
+++ b/Composer/vendor/phpunit/phpunit/PHPUnit/Util/GlobalState.php | |
@@ -112,7 +112,7 @@ public static function backupGlobals(array $blacklist) | |
!in_array($key, $superGlobalArrays) && | |
!in_array($key, $blacklist) && | |
!$GLOBALS[$key] instanceof Closure) { | |
- self::$globals['GLOBALS'][$key] = serialize($GLOBALS[$key]); | |
+ self::$globals['GLOBALS'][$key] = $GLOBALS[$key]; | |
} | |
} | |
} | |
@@ -138,16 +138,12 @@ public static function restoreGlobals(array $blacklist) | |
!in_array($key, $superGlobalArrays) && | |
!in_array($key, $blacklist)) { | |
if (isset(self::$globals['GLOBALS'][$key])) { | |
- $GLOBALS[$key] = unserialize( | |
- self::$globals['GLOBALS'][$key] | |
- ); | |
+ $GLOBALS[$key] = self::$globals['GLOBALS'][$key]; | |
} else { | |
unset($GLOBALS[$key]); | |
} | |
} | |
} | |
- | |
- self::$globals = array(); | |
} | |
protected static function backupSuperGlobalArray($superGlobalArray) |
Meanwhile, this hack is obsolete for TYPO3 CMS core. We drastically reduced unit test bootstrap and the globals are much smaller now.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Our tests rely on backupGlobals, we're manipulating stuff in GLOBALS a lot, the feature itself is very convenient for us.
But TYPO3 CMS puts lots of stuff into GLOBALS, for example some pretty big arrays. Serializing this all the time eats ~80% of unit test runtime, so our tests can be speed up by factor 5 if we suppress the serialization like done with the above patch.
The only drawback of not serializing is that manipulated objects in global scope can be changed by tests and are not correctly reconstituted again, but this is not an issue in our case.
Maybe we could have a phpunit setting to disable this serialization? I could come up with a patch, if you give green light for the idea, Sebastian.