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;
25 global $wgLanguageConverterCacheType, $wgUseDatabaseMessages;
26 global $wgLocaltimezone, $wgLocalisationCacheConf;
28 $wgMainCacheType = CACHE_NONE
;
29 $wgMessageCacheType = CACHE_NONE
;
30 $wgParserCacheType = CACHE_NONE
;
31 $wgLanguageConverterCacheType = CACHE_NONE
;
33 $wgUseDatabaseMessages = false; # Set for future resets
35 // Assume UTC for testing purposes
36 $wgLocaltimezone = 'UTC';
38 $wgLocalisationCacheConf['storeClass'] = 'LCStore_Null';
40 public function execute() { }
41 public function getDbType() {
42 return Maintenance
::DB_ADMIN
;
46 $maintClass = 'PHPUnitMaintClass';
47 require( RUN_MAINTENANCE_IF_MAIN
);
49 if( !in_array( '--configuration', $_SERVER['argv'] ) ) {
50 //Hack to eliminate the need to use the Makefile (which sucks ATM)
51 array_splice( $_SERVER['argv'], 1, 0,
52 array( '--configuration', $IP . '/tests/phpunit/suite.xml' ) );
55 require_once( 'PHPUnit/Runner/Version.php' );
56 if( version_compare( PHPUnit_Runner_Version
::id(), '3.5.0', '<' ) ) {
57 die( 'PHPUnit 3.5 or later required, you have ' . PHPUnit_Runner_Version
::id() . ".\n" );
59 require_once( 'PHPUnit/Autoload.php' );
61 require_once( "$IP/tests/TestsAutoLoader.php" );
62 MediaWikiPHPUnitCommand
::main();