Revert r103978, r103979 -- screwed something up, breaks jQuery minification.
[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 'use-normal-tables' => false,
10 'reuse-db' => false,
11 );
12
13 public function __construct() {
14 foreach( self::$additionalOptions as $option => $default ) {
15 $this->longOptions[$option] = $option . 'Handler';
16 }
17
18 }
19
20 public static function main( $exit = true ) {
21 $command = new self;
22
23 if( wfIsWindows() ) {
24 # Windows does not come anymore with ANSI.SYS loaded by default
25 # PHPUnit uses the suite.xml parameters to enable/disable colors
26 # which can be then forced to be enabled with --colors.
27 # The below code inject a parameter just like if the user called
28 # phpunit with a --no-color option (which does not exist). It
29 # overrides the suite.xml setting.
30 # Probably fix bug 29226
31 $command->arguments['colors'] = false;
32 }
33
34 # Makes MediaWiki PHPUnit directory includable so the PHPUnit will
35 # be able to resolve relative files inclusion such as suites/*
36 # PHPUnit uses stream_resolve_include_path() internally
37 # See bug 32022
38 set_include_path(
39 dirname( __FILE__ )
40 .PATH_SEPARATOR
41 . get_include_path()
42 );
43
44 $command->run($_SERVER['argv'], $exit);
45 }
46
47 public function __call( $func, $args ) {
48
49 if( substr( $func, -7 ) == 'Handler' ) {
50 if( is_null( $args[0] ) ) $args[0] = true; //Booleans
51 self::$additionalOptions[substr( $func, 0, -7 ) ] = $args[0];
52 }
53 }
54
55 public function showHelp() {
56 parent::showHelp();
57
58 print <<<EOT
59
60 ParserTest-specific options:
61
62 --regex="<regex>" Only run parser tests that match the given regex
63 --file="<filename>" Prints the version and exits.
64 --keep-uploads Re-use the same upload directory for each test, don't delete it
65
66
67 Database options:
68 --use-normal-tables Use normal DB tables.
69 --reuse-db Init DB only if tables are missing and keep after finish.
70
71
72 EOT;
73 }
74
75 }