MediaWiki  REL1_31
TestSetup.php
Go to the documentation of this file.
1 <?php
2 
6 class TestSetup {
11  public static function applyInitialConfig() {
21 
22  // wfWarn should cause tests to fail
24 
25  // Make sure all caches and stashes are either disabled or use
26  // in-process cache only to prevent tests from using any preconfigured
27  // cache meant for the local wiki from outside the test run.
28  // See also MediaWikiTestCase::run() which mocks CACHE_DB and APC.
29 
30  // Disabled in DefaultSettings, override local settings
33  // Uses CACHE_ANYTHING in DefaultSettings, use hash instead of db
38  // Uses db-replicated in DefaultSettings
39  $wgMainStash = 'hash';
40  // Use memory job queue
41  $wgJobTypeConf = [
42  'default' => [ 'class' => JobQueueMemory::class, 'order' => 'fifo' ],
43  ];
44 
45  $wgUseDatabaseMessages = false; # Set for future resets
46 
47  // Assume UTC for testing purposes
48  $wgLocaltimezone = 'UTC';
49 
51 
52  // Do not bother updating search tables
54 
55  // Generic MediaWiki\Session\SessionManager configuration for tests
56  // We use CookieSessionProvider because things might be expecting
57  // cookies to show up in a FauxRequest somewhere.
59  [
61  'args' => [ [
62  'priority' => 30,
63  'callUserSetCookiesHook' => true,
64  ] ],
65  ],
66  ];
67 
68  // Single-iteration PBKDF2 session secret derivation, for speed.
70 
71  // Generic AuthManager configuration for testing
73  'preauth' => [],
74  'primaryauth' => [
75  [
77  'args' => [ [
78  'authoritative' => false,
79  ] ],
80  ],
81  [
83  'args' => [ [
84  'authoritative' => true,
85  ] ],
86  ],
87  ],
88  'secondaryauth' => [],
89  ];
91 
92  // T46192 Do not attempt to send a real e-mail
93  Hooks::clear( 'AlternateUserMailer' );
95  'AlternateUserMailer',
96  function () {
97  return false;
98  }
99  );
100  // xdebug's default of 100 is too low for MediaWiki
101  ini_set( 'xdebug.max_nesting_level', 1000 );
102 
103  // Bug T116683 serialize_precision of 100
104  // may break testing against floating point values
105  // treated with PHP's serialize()
106  ini_set( 'serialize_precision', 17 );
107 
108  // TODO: we should call MediaWikiTestCase::prepareServices( new GlobalVarConfig() ) here.
109  // But PHPUnit may not be loaded yet, so we have to wait until just
110  // before PHPUnit_TextUI_Command::main() is executed.
111  }
112 
113 }
$wgAuthManagerConfig
$wgAuthManagerConfig
Configure AuthManager.
Definition: DefaultSettings.php:4564
$wgJobTypeConf
$wgJobTypeConf
Map of job types to configuration arrays.
Definition: DefaultSettings.php:7545
CACHE_NONE
const CACHE_NONE
Definition: Defines.php:112
MediaWiki\Auth\AuthManagerAuthPlugin
Backwards-compatibility wrapper for AuthManager via $wgAuth.
Definition: AuthManagerAuthPlugin.php:31
$wgMessageCacheType
$wgMessageCacheType
The cache type for storing the contents of the MediaWiki namespace.
Definition: DefaultSettings.php:2279
Hooks\clear
static clear( $name)
Clears hooks registered via Hooks::register().
Definition: Hooks.php:66
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:37
$wgLanguageConverterCacheType
$wgLanguageConverterCacheType
The cache type for storing language conversion tables, which are used when parsing certain text and i...
Definition: DefaultSettings.php:2304
$wgUseDatabaseMessages
$wgUseDatabaseMessages
Translation using MediaWiki: namespace.
Definition: DefaultSettings.php:3043
TestSetup\applyInitialConfig
static applyInitialConfig()
This should be called before Setup.php, e.g.
Definition: TestSetup.php:11
$wgParserCacheType
$wgParserCacheType
The cache type for storing article HTML.
Definition: DefaultSettings.php:2287
$wgLocalisationCacheConf
$wgLocalisationCacheConf
Localisation cache configuration.
Definition: DefaultSettings.php:2535
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:95
$wgSessionPbkdf2Iterations
$wgSessionPbkdf2Iterations
Number of internal PBKDF2 iterations to use when deriving session secrets.
Definition: DefaultSettings.php:2469
Hooks\register
static register( $name, $callback)
Attach an event handler to a given hook.
Definition: Hooks.php:49
future
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such and we might be restricted by PHP settings such as safe mode or open_basedir We cannot assume that the software even has read access anywhere useful Many shared hosts run all users web applications under the same so they can t rely on Unix and must forbid reads to even standard directories like tmp lest users read each others files We cannot assume that the user has the ability to install or run any programs not written as web accessible PHP scripts Since anything that works on cheap shared hosting will work if you have shell or root access MediaWiki s design is based around catering to the lowest common denominator Although we support higher end setups as the way many things work by default is tailored toward shared hosting These defaults are unconventional from the point of view of and they certainly aren t ideal for someone who s installing MediaWiki as MediaWiki does not conform to normal Unix filesystem layout Hopefully we ll offer direct support for standard layouts in the future
Definition: distributors.txt:43
$wgDevelopmentWarnings
$wgDevelopmentWarnings
If set to true MediaWiki will throw notices for some possible error conditions and for deprecated fun...
Definition: DefaultSettings.php:6343
$wgSearchType
$wgSearchType
Search type.
Definition: DefaultSettings.php:1857
$wgSessionCacheType
$wgSessionCacheType
The cache type for storing session data.
Definition: DefaultSettings.php:2294
$wgLocaltimezone
$wgLocaltimezone
Fake out the timezone that the server thinks it's in.
Definition: DefaultSettings.php:3157
TestSetup
Common code for test environment initialisation and teardown.
Definition: TestSetup.php:6
$wgMainCacheType
CACHE_MEMCACHED $wgMainCacheType
Definition: memcached.txt:63
$wgSessionProviders
$wgSessionProviders
MediaWiki\Session\SessionProvider configuration.
Definition: DefaultSettings.php:4971
class
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:56
$wgAuth
$wgAuth $wgAuth
Authentication plugin.
Definition: DefaultSettings.php:7418
$wgMainStash
$wgMainStash
Main object stash type.
Definition: DefaultSettings.php:2423
$wgMainWANCache
$wgMainWANCache
Main Wide-Area-Network cache type.
Definition: DefaultSettings.php:2364