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;
19 global $wgDevelopmentWarnings;
20 global $wgSessionProviders, $wgSessionPbkdf2Iterations;
21 global $wgJobTypeConf;
22 global $wgAuthManagerConfig, $wgAuth;
24 // wfWarn should cause tests to fail
25 $wgDevelopmentWarnings = true;
27 // Make sure all caches and stashes are either disabled or use
28 // in-process cache only to prevent tests from using any preconfigured
29 // cache meant for the local wiki from outside the test run.
30 // See also MediaWikiTestCase::run() which mocks CACHE_DB and APC.
32 // Disabled in DefaultSettings, override local settings
34 $wgMainCacheType = CACHE_NONE
;
35 // Uses CACHE_ANYTHING in DefaultSettings, use hash instead of db
39 $wgLanguageConverterCacheType = 'hash';
40 // Uses db-replicated in DefaultSettings
41 $wgMainStash = 'hash';
42 // Use memory job queue
44 'default' => [ 'class' => 'JobQueueMemory', 'order' => 'fifo' ],
47 $wgUseDatabaseMessages = false; # Set for future resets
49 // Assume UTC for testing purposes
50 $wgLocaltimezone = 'UTC';
52 $wgLocalisationCacheConf['storeClass'] = 'LCStoreNull';
54 // Do not bother updating search tables
55 $wgSearchType = 'SearchEngineDummy';
57 // Generic MediaWiki\Session\SessionManager configuration for tests
58 // We use CookieSessionProvider because things might be expecting
59 // cookies to show up in a FauxRequest somewhere.
60 $wgSessionProviders = [
62 'class' => MediaWiki\Session\CookieSessionProvider
::class,
65 'callUserSetCookiesHook' => true,
70 // Single-iteration PBKDF2 session secret derivation, for speed.
71 $wgSessionPbkdf2Iterations = 1;
73 // Generic AuthManager configuration for testing
74 $wgAuthManagerConfig = [
78 'class' => MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider
::class,
80 'authoritative' => false,
84 'class' => MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProvider
::class,
86 'authoritative' => true,
90 'secondaryauth' => [],
92 $wgAuth = new MediaWiki\Auth\
AuthManagerAuthPlugin();
94 // Bug 44192 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 );
110 // TODO: we should call MediaWikiTestCase::prepareServices( new GlobalVarConfig() ) here.
111 // But PHPUnit may not be loaded yet, so we have to wait until just
112 // before PHPUnit_TextUI_Command::main() is executed.