4 * Common code for test environment initialisation and teardown
8 * This should be called before Setup.php, e.g. from the finalSetup() method
9 * of a Maintenance subclass
11 public static function applyInitialConfig() {
12 global $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType, $wgMainWANCache;
14 global $wgLanguageConverterCacheType, $wgUseDatabaseMessages;
15 global $wgLocaltimezone, $wgLocalisationCacheConf;
17 global $wgDevelopmentWarnings;
18 global $wgSessionProviders, $wgSessionPbkdf2Iterations;
19 global $wgJobTypeConf;
20 global $wgAuthManagerConfig;
21 global $wgShowExceptionDetails;
23 $wgShowExceptionDetails = true;
25 // wfWarn should cause tests to fail
26 $wgDevelopmentWarnings = true;
28 // Make sure all caches and stashes are either disabled or use
29 // in-process cache only to prevent tests from using any preconfigured
30 // cache meant for the local wiki from outside the test run.
31 // See also MediaWikiTestCase::run() which mocks CACHE_DB and APC.
33 // Disabled in DefaultSettings, override local settings
35 $wgMainCacheType = CACHE_NONE
;
36 // Uses CACHE_ANYTHING in DefaultSettings, use hash instead of db
40 $wgLanguageConverterCacheType = 'hash';
41 // Uses db-replicated in DefaultSettings
42 $wgMainStash = 'hash';
43 // Use memory job queue
45 'default' => [ 'class' => JobQueueMemory
::class, 'order' => 'fifo' ],
48 $wgUseDatabaseMessages = false; # Set for future resets
50 // Assume UTC for testing purposes
51 $wgLocaltimezone = 'UTC';
53 $wgLocalisationCacheConf['storeClass'] = LCStoreNull
::class;
55 // Do not bother updating search tables
56 $wgSearchType = SearchEngineDummy
::class;
58 // Generic MediaWiki\Session\SessionManager configuration for tests
59 // We use CookieSessionProvider because things might be expecting
60 // cookies to show up in a FauxRequest somewhere.
61 $wgSessionProviders = [
63 'class' => MediaWiki\Session\CookieSessionProvider
::class,
66 'callUserSetCookiesHook' => true,
71 // Single-iteration PBKDF2 session secret derivation, for speed.
72 $wgSessionPbkdf2Iterations = 1;
74 // Generic AuthManager configuration for testing
75 $wgAuthManagerConfig = [
79 'class' => MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider
::class,
81 'authoritative' => false,
85 'class' => MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProvider
::class,
87 'authoritative' => true,
91 'secondaryauth' => [],
94 // T46192 Do not attempt to send a real e-mail
95 Hooks
::clear( 'AlternateUserMailer' );
97 'AlternateUserMailer',
102 // xdebug's default of 100 is too low for MediaWiki
103 ini_set( 'xdebug.max_nesting_level', 1000 );
105 // Bug T116683 serialize_precision of 100
106 // may break testing against floating point values
107 // treated with PHP's serialize()
108 ini_set( 'serialize_precision', 17 );