3 use MediaWiki\MediaWikiServices
;
6 * Common code for test environment initialisation and teardown
10 * This should be called before Setup.php, e.g. from the finalSetup() method
11 * of a Maintenance subclass
13 public static function applyInitialConfig() {
14 global $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType, $wgMainWANCache;
16 global $wgLanguageConverterCacheType, $wgUseDatabaseMessages;
17 global $wgLocaltimezone, $wgLocalisationCacheConf;
18 global $wgDevelopmentWarnings;
19 global $wgSessionProviders, $wgSessionPbkdf2Iterations;
20 global $wgJobTypeConf;
21 global $wgAuthManagerConfig, $wgAuth;
23 // wfWarn should cause tests to fail
24 $wgDevelopmentWarnings = true;
26 // Make sure all caches and stashes are either disabled or use
27 // in-process cache only to prevent tests from using any preconfigured
28 // cache meant for the local wiki from outside the test run.
29 // See also MediaWikiTestCase::run() which mocks CACHE_DB and APC.
31 // Disabled in DefaultSettings, override local settings
33 $wgMainCacheType = CACHE_NONE
;
34 // Uses CACHE_ANYTHING in DefaultSettings, use hash instead of db
38 $wgLanguageConverterCacheType = 'hash';
39 // Uses db-replicated in DefaultSettings
40 $wgMainStash = 'hash';
41 // Use memory job queue
43 'default' => [ 'class' => 'JobQueueMemory', 'order' => 'fifo' ],
46 $wgUseDatabaseMessages = false; # Set for future resets
48 // Assume UTC for testing purposes
49 $wgLocaltimezone = 'UTC';
51 $wgLocalisationCacheConf['storeClass'] = 'LCStoreNull';
53 // Generic MediaWiki\Session\SessionManager configuration for tests
54 // We use CookieSessionProvider because things might be expecting
55 // cookies to show up in a FauxRequest somewhere.
56 $wgSessionProviders = [
58 'class' => MediaWiki\Session\CookieSessionProvider
::class,
61 'callUserSetCookiesHook' => true,
66 // Single-iteration PBKDF2 session secret derivation, for speed.
67 $wgSessionPbkdf2Iterations = 1;
69 // Generic AuthManager configuration for testing
70 $wgAuthManagerConfig = [
74 'class' => MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider
::class,
76 'authoritative' => false,
80 'class' => MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProvider
::class,
82 'authoritative' => true,
86 'secondaryauth' => [],
88 $wgAuth = new MediaWiki\Auth\
AuthManagerAuthPlugin();
90 // Bug 44192 Do not attempt to send a real e-mail
91 Hooks
::clear( 'AlternateUserMailer' );
93 'AlternateUserMailer',
98 // xdebug's default of 100 is too low for MediaWiki
99 ini_set( 'xdebug.max_nesting_level', 1000 );
101 // Bug T116683 serialize_precision of 100
102 // may break testing against floating point values
103 // treated with PHP's serialize()
104 ini_set( 'serialize_precision', 17 );
106 // TODO: we should call MediaWikiTestCase::prepareServices( new GlobalVarConfig() ) here.
107 // But PHPUnit may not be loaded yet, so we have to wait until just
108 // before PHPUnit_TextUI_Command::main() is executed.