+ $GLOBALS[$key] = $value;
+ }
+ }
+
+ /**
+ * Stashes the global, will be restored in tearDown()
+ *
+ * Individual test functions may override globals through the setMwGlobals() function
+ * or directly. When directly overriding globals their keys should first be passed to this
+ * method in setUp to avoid breaking global state for other tests
+ *
+ * That way all other tests are executed with the same settings (instead of using the
+ * unreliable local settings for most tests and fix it only for some tests).
+ *
+ * @param array|string $globalKeys Key to the global variable, or an array of keys.
+ *
+ * @throws Exception when trying to stash an unset global
+ * @since 1.23
+ */
+ protected function stashMwGlobals( $globalKeys ) {
+ if ( is_string( $globalKeys ) ) {
+ $globalKeys = array( $globalKeys );
+ }
+
+ foreach ( $globalKeys as $globalKey ) {