2010-12-29 02:23:51 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
class MediaWikiPHPUnitCommand extends PHPUnit_TextUI_Command {
|
2011-06-02 19:32:45 +00:00
|
|
|
|
2013-01-28 10:27:15 +00:00
|
|
|
public static $additionalOptions = array(
|
2011-06-02 19:32:45 +00:00
|
|
|
'regex=' => false,
|
2011-01-01 05:53:04 +00:00
|
|
|
'file=' => false,
|
2012-01-22 00:34:04 +00:00
|
|
|
'use-filebackend=' => false,
|
2012-10-01 14:05:22 +00:00
|
|
|
'use-bagostuff=' => false,
|
2013-02-08 18:52:54 +00:00
|
|
|
'use-jobqueue=' => false,
|
2011-01-01 05:53:04 +00:00
|
|
|
'keep-uploads' => false,
|
2011-11-10 13:29:32 +00:00
|
|
|
'use-normal-tables' => false,
|
|
|
|
|
'reuse-db' => false,
|
2012-12-10 11:03:13 +00:00
|
|
|
'wiki=' => false,
|
2013-07-17 19:23:28 +00:00
|
|
|
'debug-tests' => false,
|
2011-01-01 05:53:04 +00:00
|
|
|
);
|
2011-06-02 19:32:45 +00:00
|
|
|
|
2010-12-29 02:23:51 +00:00
|
|
|
public function __construct() {
|
2013-02-14 11:22:13 +00:00
|
|
|
foreach ( self::$additionalOptions as $option => $default ) {
|
2011-01-01 05:53:04 +00:00
|
|
|
$this->longOptions[$option] = $option . 'Handler';
|
|
|
|
|
}
|
2010-12-29 02:23:51 +00:00
|
|
|
}
|
2011-06-02 19:32:45 +00:00
|
|
|
|
2013-08-24 15:06:25 +00:00
|
|
|
protected function handleArguments( array $argv ) {
|
2013-07-17 19:23:28 +00:00
|
|
|
parent::handleArguments( $argv );
|
|
|
|
|
|
|
|
|
|
if ( !isset( $this->arguments['listeners'] ) ) {
|
|
|
|
|
$this->arguments['listeners'] = array();
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-24 15:06:25 +00:00
|
|
|
foreach ( $this->options[0] as $option ) {
|
|
|
|
|
switch ( $option[0] ) {
|
2013-07-17 19:23:28 +00:00
|
|
|
case '--debug-tests':
|
|
|
|
|
$this->arguments['listeners'][] = new MediaWikiPHPUnitTestListener( 'PHPUnitCommand' );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-29 02:23:51 +00:00
|
|
|
public static function main( $exit = true ) {
|
2011-06-02 19:32:45 +00:00
|
|
|
$command = new self;
|
2013-02-14 11:22:13 +00:00
|
|
|
$command->run( $_SERVER['argv'], $exit );
|
2011-06-02 19:32:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function __call( $func, $args ) {
|
|
|
|
|
|
2013-02-14 11:22:13 +00:00
|
|
|
if ( substr( $func, -7 ) == 'Handler' ) {
|
|
|
|
|
if ( is_null( $args[0] ) ) {
|
|
|
|
|
$args[0] = true;
|
|
|
|
|
} //Booleans
|
|
|
|
|
self::$additionalOptions[substr( $func, 0, -7 )] = $args[0];
|
2011-01-01 05:53:04 +00:00
|
|
|
}
|
2010-12-29 02:23:51 +00:00
|
|
|
}
|
2011-06-02 19:32:45 +00:00
|
|
|
|
2011-01-01 06:49:00 +00:00
|
|
|
public function showHelp() {
|
|
|
|
|
parent::showHelp();
|
2011-06-02 19:32:45 +00:00
|
|
|
|
2011-01-01 06:49:00 +00:00
|
|
|
print <<<EOT
|
|
|
|
|
|
|
|
|
|
ParserTest-specific options:
|
|
|
|
|
--regex="<regex>" Only run parser tests that match the given regex
|
2013-05-11 06:01:36 +00:00
|
|
|
--file="<filename>" File describing parser tests
|
2011-01-01 06:49:00 +00:00
|
|
|
--keep-uploads Re-use the same upload directory for each test, don't delete it
|
2011-06-02 19:32:45 +00:00
|
|
|
|
2011-11-10 13:29:32 +00:00
|
|
|
Database options:
|
|
|
|
|
--use-normal-tables Use normal DB tables.
|
|
|
|
|
--reuse-db Init DB only if tables are missing and keep after finish.
|
|
|
|
|
|
2013-07-17 19:23:28 +00:00
|
|
|
Debugging options:
|
|
|
|
|
--debug-tests Log testing activity to the PHPUnitCommand log channel.
|
|
|
|
|
|
2011-01-01 06:49:00 +00:00
|
|
|
EOT;
|
|
|
|
|
}
|
2010-12-29 02:23:51 +00:00
|
|
|
}
|