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,
15 'debug-tests' => false,
18 public function __construct() {
19 foreach ( self
::$additionalOptions as $option => $default ) {
20 $this->longOptions
[$option] = $option . 'Handler';
24 protected function handleArguments( array $argv ) {
25 parent
::handleArguments( $argv );
27 if ( !isset( $this->arguments
['listeners'] ) ) {
28 $this->arguments
['listeners'] = array();
31 foreach ( $this->options
[0] as $option ) {
32 switch ( $option[0] ) {
34 $this->arguments
['listeners'][] = new MediaWikiPHPUnitTestListener( 'PHPUnitCommand' );
40 public static function main( $exit = true ) {
43 # Makes MediaWiki PHPUnit directory includable so the PHPUnit will
44 # be able to resolve relative files inclusion such as suites/*
45 # PHPUnit uses stream_resolve_include_path() internally
53 $command->run( $_SERVER['argv'], $exit );
56 public function __call( $func, $args ) {
58 if ( substr( $func, -7 ) == 'Handler' ) {
59 if ( is_null( $args[0] ) ) {
62 self
::$additionalOptions[substr( $func, 0, -7 )] = $args[0];
66 public function run( array $argv, $exit = true ) {
67 wfProfileIn( __METHOD__
);
69 $ret = parent
::run( $argv, false );
71 wfProfileOut( __METHOD__
);
73 // Return to real wiki db, so profiling data is preserved
74 MediaWikiTestCase
::teardownTestDB();
76 // Log profiling data, e.g. in the database or UDP
86 public function showHelp() {
91 ParserTest-specific options:
92 --regex="<regex>" Only run parser tests that match the given regex
93 --file="<filename>" File describing parser tests
94 --keep-uploads Re-use the same upload directory for each test, don't delete it
97 --use-normal-tables Use normal DB tables.
98 --reuse-db Init DB only if tables are missing and keep after finish.
101 --debug-tests Log testing activity to the PHPUnitCommand log channel.