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