fa863fc57f4b4e95cdea86c0f512164c92424826
[lhc/web/wiklou.git] / tests / phpunit / MediaWikiPHPUnitCommand.php
1 <?php
2
3 class MediaWikiPHPUnitCommand extends PHPUnit_TextUI_Command {
4
5 public static $additionalOptions = array(
6 'regex=' => false,
7 'file=' => false,
8 'use-filebackend=' => false,
9 'use-bagostuff=' => false,
10 'use-jobqueue=' => false,
11 'keep-uploads' => false,
12 'use-normal-tables' => false,
13 'reuse-db' => false,
14 'wiki=' => false,
15 'debug-tests' => false,
16 );
17
18 public function __construct() {
19 foreach ( self::$additionalOptions as $option => $default ) {
20 $this->longOptions[$option] = $option . 'Handler';
21 }
22 }
23
24 protected function handleArguments( array $argv ) {
25 parent::handleArguments( $argv );
26
27 if ( !isset( $this->arguments['listeners'] ) ) {
28 $this->arguments['listeners'] = array();
29 }
30
31 foreach ( $this->options[0] as $option ) {
32 switch ( $option[0] ) {
33 case '--debug-tests':
34 $this->arguments['listeners'][] = new MediaWikiPHPUnitTestListener( 'PHPUnitCommand' );
35 break;
36 }
37 }
38 }
39
40 public static function main( $exit = true ) {
41 $command = new self;
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] ) ) {
49 $args[0] = true;
50 } //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 --regex="<regex>" Only run parser tests that match the given regex
62 --file="<filename>" File describing parser tests
63 --keep-uploads Re-use the same upload directory for each test, don't delete it
64
65 Database options:
66 --use-normal-tables Use normal DB tables.
67 --reuse-db Init DB only if tables are missing and keep after finish.
68
69 Debugging options:
70 --debug-tests Log testing activity to the PHPUnitCommand log channel.
71
72 EOT;
73 }
74 }