Added merge() function to BagOStuff for CAS-like functionality.
[mediawiki.git] / tests / phpunit / MediaWikiPHPUnitCommand.php
blob3894435d994046891c6f95c28dad9850cde856b9
1 <?php
3 class MediaWikiPHPUnitCommand extends PHPUnit_TextUI_Command {
5 static $additionalOptions = array(
6 'regex=' => false,
7 'file=' => false,
8 'use-filebackend=' => false,
9 'use-bagostuff=' => false,
10 'keep-uploads' => false,
11 'use-normal-tables' => false,
12 'reuse-db' => false,
13 'wiki=' => false,
16 public function __construct() {
17 foreach( self::$additionalOptions as $option => $default ) {
18 $this->longOptions[$option] = $option . 'Handler';
23 public static function main( $exit = true ) {
24 $command = new self;
26 if( wfIsWindows() ) {
27 # Windows does not come anymore with ANSI.SYS loaded by default
28 # PHPUnit uses the suite.xml parameters to enable/disable colors
29 # which can be then forced to be enabled with --colors.
30 # The below code inject a parameter just like if the user called
31 # phpunit with a --no-color option (which does not exist). It
32 # overrides the suite.xml setting.
33 # Probably fix bug 29226
34 $command->arguments['colors'] = false;
37 # Makes MediaWiki PHPUnit directory includable so the PHPUnit will
38 # be able to resolve relative files inclusion such as suites/*
39 # PHPUnit uses stream_resolve_include_path() internally
40 # See bug 32022
41 set_include_path(
42 __DIR__
43 .PATH_SEPARATOR
44 . get_include_path()
47 $command->run($_SERVER['argv'], $exit);
50 public function __call( $func, $args ) {
52 if( substr( $func, -7 ) == 'Handler' ) {
53 if( is_null( $args[0] ) ) $args[0] = true; //Booleans
54 self::$additionalOptions[substr( $func, 0, -7 ) ] = $args[0];
58 public function run( array $argv, $exit = true ) {
59 wfProfileIn( __METHOD__ );
61 $ret = parent::run( $argv, false );
63 wfProfileOut( __METHOD__ );
65 // Return to real wiki db, so profiling data is preserved
66 MediaWikiTestCase::teardownTestDB();
68 // Log profiling data, e.g. in the database or UDP
69 wfLogProfilingData();
71 if ( $exit ) {
72 exit( $ret );
73 } else {
74 return $ret;
78 public function showHelp() {
79 parent::showHelp();
81 print <<<EOT
83 ParserTest-specific options:
85 --regex="<regex>" Only run parser tests that match the given regex
86 --file="<filename>" Prints the version and exits.
87 --keep-uploads Re-use the same upload directory for each test, don't delete it
90 Database options:
91 --use-normal-tables Use normal DB tables.
92 --reuse-db Init DB only if tables are missing and keep after finish.
95 EOT;