3 class MediaWikiPHPUnitCommand
extends PHPUnit_TextUI_Command
{
5 static $additionalOptions = array(
8 'use-filebackend=' => false,
9 'keep-uploads' => false,
10 'use-normal-tables' => false,
15 public function __construct() {
16 foreach( self
::$additionalOptions as $option => $default ) {
17 $this->longOptions
[$option] = $option . 'Handler';
22 public static function main( $exit = true ) {
26 # Windows does not come anymore with ANSI.SYS loaded by default
27 # PHPUnit uses the suite.xml parameters to enable/disable colors
28 # which can be then forced to be enabled with --colors.
29 # The below code inject a parameter just like if the user called
30 # phpunit with a --no-color option (which does not exist). It
31 # overrides the suite.xml setting.
32 # Probably fix bug 29226
33 $command->arguments
['colors'] = false;
36 # Makes MediaWiki PHPUnit directory includable so the PHPUnit will
37 # be able to resolve relative files inclusion such as suites/*
38 # PHPUnit uses stream_resolve_include_path() internally
46 $command->run($_SERVER['argv'], $exit);
49 public function __call( $func, $args ) {
51 if( substr( $func, -7 ) == 'Handler' ) {
52 if( is_null( $args[0] ) ) $args[0] = true; //Booleans
53 self
::$additionalOptions[substr( $func, 0, -7 ) ] = $args[0];
57 public function run( array $argv, $exit = true ) {
58 wfProfileIn( __METHOD__
);
60 $ret = parent
::run( $argv, false );
62 wfProfileOut( __METHOD__
);
64 // Return to real wiki db, so profiling data is preserved
65 MediaWikiTestCase
::teardownTestDB();
67 // Log profiling data, e.g. in the database or UDP
77 public function showHelp() {
82 ParserTest-specific options:
84 --regex="<regex>" Only run parser tests that match the given regex
85 --file="<filename>" Prints the version and exits.
86 --keep-uploads Re-use the same upload directory for each test, don't delete it
90 --use-normal-tables Use normal DB tables.
91 --reuse-db Init DB only if tables are missing and keep after finish.