(bug 19195) Make user IDs more readily available with the API
[lhc/web/wiklou.git] / tests / phpunit / phpunit.php
1 #!/usr/bin/env php
2 <?php
3 /**
4 * Bootstrapping for MediaWiki PHPUnit tests
5 *
6 * @file
7 */
8
9 /* Configuration */
10
11 // Evaluate the include path relative to this file
12 $IP = dirname( dirname( dirname( __FILE__ ) ) );
13
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 );
16
17 // Start up MediaWiki in command-line mode
18 require_once( "$IP/maintenance/Maintenance.php" );
19
20 class PHPUnitMaintClass extends Maintenance {
21 public function finalSetup() {
22 parent::finalSetup();
23
24 global $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType;
25 global $wgLanguageConverterCacheType, $wgUseDatabaseMessages;
26 global $wgLocaltimezone, $wgLocalisationCacheConf;
27
28 $wgMainCacheType = CACHE_NONE;
29 $wgMessageCacheType = CACHE_NONE;
30 $wgParserCacheType = CACHE_NONE;
31 $wgLanguageConverterCacheType = CACHE_NONE;
32
33 $wgUseDatabaseMessages = false; # Set for future resets
34
35 // Assume UTC for testing purposes
36 $wgLocaltimezone = 'UTC';
37
38 $wgLocalisationCacheConf['storeClass'] = 'LCStore_Null';
39 }
40 public function execute() { }
41 public function getDbType() {
42 return Maintenance::DB_ADMIN;
43 }
44 }
45
46 $maintClass = 'PHPUnitMaintClass';
47 require( RUN_MAINTENANCE_IF_MAIN );
48
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' ) );
53 }
54
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" );
58 }
59 require_once( 'PHPUnit/Autoload.php' );
60
61 require_once( "$IP/tests/TestsAutoLoader.php" );
62 MediaWikiPHPUnitCommand::main();
63