4 * Bootstrapping for MediaWiki PHPUnit tests
11 // Evaluate the include path relative to this file
12 $IP = dirname( dirname( dirname( __FILE__
) ) );
14 // Set a flag which can be used to detect when other scripts have been entered through this entry point or not
15 define( 'MW_PHPUNIT_TEST', true );
17 // Start up MediaWiki in command-line mode
18 require_once( "$IP/maintenance/Maintenance.php" );
20 class PHPUnitMaintClass
extends Maintenance
{
21 public function finalSetup() {
24 global $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType, $wgUseDatabaseMessages;
26 $wgMainCacheType = CACHE_NONE
;
27 $wgMessageCacheType = CACHE_NONE
;
28 $wgParserCacheType = CACHE_NONE
;
29 $wgUseDatabaseMessages = false; # Set for future resets
31 public function execute() { }
32 public function getDbType() {
33 return Maintenance
::DB_ADMIN
;
37 $maintClass = 'PHPUnitMaintClass';
38 require( RUN_MAINTENANCE_IF_MAIN
);
40 // Assume UTC for testing purposes
41 $wgLocaltimezone = 'UTC';
43 $wgLocalisationCacheConf['storeClass'] = 'LCStore_Null';
45 if( !in_array( '--configuration', $_SERVER['argv'] ) ) {
46 //Hack to eliminate the need to use the Makefile (which sucks ATM)
47 $_SERVER['argv'][] = '--configuration';
48 $_SERVER['argv'][] = $IP . '/tests/phpunit/suite.xml';
51 require_once( 'PHPUnit/Runner/Version.php' );
52 if( version_compare( PHPUnit_Runner_Version
::id(), '3.5.0', '>=' ) ) {
53 # PHPUnit 3.5.0 introduced a nice autoloader based on class name
54 require_once( 'PHPUnit/Autoload.php' );
56 # Keep the old pre PHPUnit 3.5.0 behaviour for compatibility
57 require_once( 'PHPUnit/TextUI/Command.php' );
60 require_once( "$IP/tests/TestsAutoLoader.php" );
61 MediaWikiPHPUnitCommand
::main();