space to tab
[lhc/web/wiklou.git] / tests / phpunit / MediaWikiPHPUnitCommand.php
1 <?php
2
3 class MediaWikiPHPUnitCommand extends PHPUnit_TextUI_Command {
4
5 static $additionalOptions = array(
6 'regex=' => false,
7 'file=' => false,
8 'keep-uploads' => false,
9 );
10
11 public function __construct() {
12 foreach( self::$additionalOptions as $option => $default ) {
13 $this->longOptions[$option] = $option . 'Handler';
14 }
15
16 }
17
18 public static function main( $exit = true ) {
19 $command = new self;
20
21 if( wfIsWindows() ) {
22 # Windows does not come anymore with ANSI.SYS loaded by default
23 # PHPUnit uses the suite.xml parameters to enable/disable colors
24 # which can be then forced to be enabled with --colors.
25 # The below code inject a parameter just like if the user called
26 # phpunit with a --no-color option (which does not exist). It
27 # overrides the suite.xml setting.
28 # Probably fix bug 29226
29 $command->arguments['colors'] = false;
30 }
31
32 # Makes MediaWiki PHPUnit directory includable so the PHPUnit will
33 # be able to resolve relative files inclusion such as suites/*
34 # PHPUnit uses stream_resolve_include_path() internally
35 # See bug 32022
36 set_include_path(
37 dirname( __FILE__ )
38 .PATH_SEPARATOR
39 . get_include_path()
40 );
41
42 $command->run($_SERVER['argv'], $exit);
43 }
44
45 public function __call( $func, $args ) {
46
47 if( substr( $func, -7 ) == 'Handler' ) {
48 if( is_null( $args[0] ) ) $args[0] = true; //Booleans
49 self::$additionalOptions[substr( $func, 0, -7 ) ] = $args[0];
50 }
51 }
52
53 public function showHelp() {
54 parent::showHelp();
55
56 print <<<EOT
57
58 ParserTest-specific options:
59
60 --regex="<regex>" Only run parser tests that match the given regex
61 --file="<filename>" Prints the version and exits.
62 --keep-uploads Re-use the same upload directory for each test, don't delete it
63
64
65 EOT;
66 }
67
68 }