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