<?php
class MediaWikiPHPUnitCommand extends PHPUnit_TextUI_Command {
- static $additionalArgs = array( 'verbose' => false );
+
+ static $additionalOptions = array(
+ 'regex=' => false,
+ 'record' => false,
+ 'file=' => false,
+ 'keep-uploads' => false,
+ );
+
+ //Fixme: These aren't shown on the --help menu
public function __construct() {
- $this->longOptions['verbose'] = 'verboseHandler';
+ foreach( self::$additionalOptions as $option => $default ) {
+ $this->longOptions[$option] = $option . 'Handler';
+ }
+
}
public static function main( $exit = true ) {
$command = new self;
$command->run($_SERVER['argv'], $exit);
}
-
- protected function verboseHandler($value) {
- self::$additionalArgs['verbose'] = true;
+
+ public function __call( $func, $args ) {
+
+ if( substr( $func, -7 ) == 'Handler' ) {
+ if( is_null( $args[0] ) ) $args[0] = true; //Booleans
+ self::$additionalOptions[substr( $func, 0, -7 ) ] = $args[0];
+ }
}
-
+
}
throw new MWException( $this->db->getType() . " is not currently supported for unit testing." );
}
}
+
+ public function getCliArg( $offset ) {
+
+ if( isset( MediaWikiPHPUnitCommand::$additionalOptions[$offset] ) ) {
+ return MediaWikiPHPUnitCommand::$additionalOptions[$offset];
+ }
+
+ }
+
+ public function setCliArg( $offset, $value ) {
+
+ MediaWikiPHPUnitCommand::$additionalOptions[$offset] = $value;
+
+ }
}
function setUp() {
global $wgContLang;
$wgContLang = Language::factory( 'en' );
+
+
+
+ //Setup CLI arguments
+ if ( $this->getCliArg( 'regex=' ) ) {
+ if ( $this->getCliArg( 'record' ) ) {
+ echo "Warning: --record cannot be used with --regex, disabling --record\n";
+ $this->setCliArg( 'record', false );
+ }
+ $this->regex = $this->getCliArg( 'regex=' );
+ } else {
+ # Matches anything
+ $this->regex = '';
+ }
+
+ $this->keepUploads = $this->getCliArg( 'keep-uploads' );
+
+
global $wgParser, $wgParserConf, $IP, $messageMemc, $wgMemc, $wgDeferredUpdateList,
$wgUser, $wgLang, $wgOut, $wgRequest, $wgStyleDirectory, $wgEnableParserCache,
if ( $wgStyleDirectory === false ) {
$wgStyleDirectory = "$IP/skins";
}
+
}
/**
public function testParserTests() {
- //global $IP;
- //$wgParserTestFiles = array( "$IP/tests/parser/testparserTests.txt" );
-
global $wgParserTestFiles;
- foreach( $wgParserTestFiles as $file ) {
+ $files = $wgParserTestFiles;
+
+ if( $this->getCliArg( 'file=' ) ) {
+ $files = array( $this->getCliArg( 'file=' ) );
+ }
+
+ foreach( $files as $file ) {
$iter = new ParserTestFileIterator( $file, $this );