Previous approach caused breakage with "Notice: Undefined index: _SERVER"
messages, see e.g.
https://gerrit.wikimedia.org/r/c/mediawiki/core/+/521268#message-
4502e6c209f53f6dc1c7cdf4f60e5045bbfb6ee4
Change-Id: Ief20e4e21fd99d219ebef865c603e336c2609ce2
Follows-Up: I16691fc8ac063705ba0c2bc63b96c4534ca8660b
Bug: T87781
$GLOBALS = [];
// Add back the minimal set of globals needed for unit tests to run for core +
// extensions/skins.
- foreach ( [ 'wgAutoloadClasses', 'wgAutoloadLocalClasses', 'IP' ] as $requiredGlobal ) {
- $GLOBALS[$requiredGlobal] = $this->unitGlobals[ $requiredGlobal ];
+ foreach ( $this->unitGlobals['wgPhpUnitBootstrapGlobals'] ?? [] as $key => $value ) {
+ $GLOBALS[ $key ] = $this->unitGlobals[ $key ];
}
}
// these variables must be defined before setup runs
$GLOBALS['IP'] = $IP;
+// Set bootstrap globals to reuse in MediaWikiUnitTestCase
+$bootstrapGlobals = [];
+foreach ( $GLOBALS as $key => $value ) {
+ $bootstrapGlobals[ $key ] = $value;
+}
+$GLOBALS['wgPhpUnitBootstrapGlobals'] = $bootstrapGlobals;
// Faking for Setup.php
$GLOBALS['wgScopeTest'] = 'MediaWiki Setup.php scope test';
$GLOBALS['wgCommandLineMode'] = true;