Reverted r86072, r86419 per CR. Lots of conflicts resolved here. Removes lineStart...
[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 $command->run($_SERVER['argv'], $exit);
32 }
33
34 public function __call( $func, $args ) {
35
36 if( substr( $func, -7 ) == 'Handler' ) {
37 if( is_null( $args[0] ) ) $args[0] = true; //Booleans
38 self::$additionalOptions[substr( $func, 0, -7 ) ] = $args[0];
39 }
40 }
41
42 public function showHelp() {
43 parent::showHelp();
44
45 print <<<EOT
46
47 ParserTest-specific options:
48
49 --regex="<regex>" Only run parser tests that match the given regex
50 --file="<filename>" Prints the version and exits.
51 --keep-uploads Re-use the same upload directory for each test, don't delete it
52
53
54 EOT;
55 }
56
57 }