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';
24 public static function main( $exit = true ) {
27 if ( wfIsWindows() ) {
28 # Windows does not come anymore with ANSI.SYS loaded by default
29 # PHPUnit uses the suite.xml parameters to enable/disable colors
30 # which can be then forced to be enabled with --colors.
31 # The below code inject a parameter just like if the user called
32 # phpunit with a --no-color option (which does not exist). It
33 # overrides the suite.xml setting.
34 # Probably fix bug 29226
35 $command->arguments
['colors'] = false;
38 # Makes MediaWiki PHPUnit directory includable so the PHPUnit will
39 # be able to resolve relative files inclusion such as suites/*
40 # PHPUnit uses stream_resolve_include_path() internally
48 $command->run( $_SERVER['argv'], $exit );
51 public function __call( $func, $args ) {
53 if ( substr( $func, -7 ) == 'Handler' ) {
54 if ( is_null( $args[0] ) ) {
57 self
::$additionalOptions[substr( $func, 0, -7 )] = $args[0];
61 public function run( array $argv, $exit = true ) {
62 wfProfileIn( __METHOD__
);
64 $ret = parent
::run( $argv, false );
66 wfProfileOut( __METHOD__
);
68 // Return to real wiki db, so profiling data is preserved
69 MediaWikiTestCase
::teardownTestDB();
71 // Log profiling data, e.g. in the database or UDP
81 public function showHelp() {
86 ParserTest-specific options:
88 --regex="<regex>" Only run parser tests that match the given regex
89 --file="<filename>" Prints the version and exits.
90 --keep-uploads Re-use the same upload directory for each test, don't delete it
94 --use-normal-tables Use normal DB tables.
95 --reuse-db Init DB only if tables are missing and keep after finish.