Index: trunk/phase3/tests/phpunit/MediaWikiPHPUnitCommand.php |
— | — | @@ -1,19 +1,34 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | class MediaWikiPHPUnitCommand extends PHPUnit_TextUI_Command { |
5 | | - static $additionalArgs = array( 'verbose' => false ); |
| 5 | + |
| 6 | + static $additionalOptions = array( |
| 7 | + 'regex=' => false, |
| 8 | + 'record' => false, |
| 9 | + 'file=' => false, |
| 10 | + 'keep-uploads' => false, |
| 11 | + ); |
| 12 | + |
| 13 | + //Fixme: These aren't shown on the --help menu |
6 | 14 | |
7 | 15 | public function __construct() { |
8 | | - $this->longOptions['verbose'] = 'verboseHandler'; |
| 16 | + foreach( self::$additionalOptions as $option => $default ) { |
| 17 | + $this->longOptions[$option] = $option . 'Handler'; |
| 18 | + } |
| 19 | + |
9 | 20 | } |
10 | 21 | |
11 | 22 | public static function main( $exit = true ) { |
12 | 23 | $command = new self; |
13 | 24 | $command->run($_SERVER['argv'], $exit); |
14 | 25 | } |
15 | | - |
16 | | - protected function verboseHandler($value) { |
17 | | - self::$additionalArgs['verbose'] = true; |
| 26 | + |
| 27 | + public function __call( $func, $args ) { |
| 28 | + |
| 29 | + if( substr( $func, -7 ) == 'Handler' ) { |
| 30 | + if( is_null( $args[0] ) ) $args[0] = true; //Booleans |
| 31 | + self::$additionalOptions[substr( $func, 0, -7 ) ] = $args[0]; |
| 32 | + } |
18 | 33 | } |
19 | | - |
| 34 | + |
20 | 35 | } |
Index: trunk/phase3/tests/phpunit/MediaWikiTestCase.php |
— | — | @@ -194,5 +194,19 @@ |
195 | 195 | throw new MWException( $this->db->getType() . " is not currently supported for unit testing." ); |
196 | 196 | } |
197 | 197 | } |
| 198 | + |
| 199 | + public function getCliArg( $offset ) { |
| 200 | + |
| 201 | + if( isset( MediaWikiPHPUnitCommand::$additionalOptions[$offset] ) ) { |
| 202 | + return MediaWikiPHPUnitCommand::$additionalOptions[$offset]; |
| 203 | + } |
| 204 | + |
| 205 | + } |
| 206 | + |
| 207 | + public function setCliArg( $offset, $value ) { |
| 208 | + |
| 209 | + MediaWikiPHPUnitCommand::$additionalOptions[$offset] = $value; |
| 210 | + |
| 211 | + } |
198 | 212 | } |
199 | 213 | |
Index: trunk/phase3/tests/phpunit/includes/parser/NewParserHelpers.php |
— | — | @@ -196,4 +196,4 @@ |
197 | 197 | |
198 | 198 | return false; |
199 | 199 | } |
200 | | -} |
\ No newline at end of file |
| 200 | +} |
Index: trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php |
— | — | @@ -19,7 +19,25 @@ |
20 | 20 | function setUp() { |
21 | 21 | global $wgContLang; |
22 | 22 | $wgContLang = Language::factory( 'en' ); |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | + //Setup CLI arguments |
| 27 | + if ( $this->getCliArg( 'regex=' ) ) { |
| 28 | + if ( $this->getCliArg( 'record' ) ) { |
| 29 | + echo "Warning: --record cannot be used with --regex, disabling --record\n"; |
| 30 | + $this->setCliArg( 'record', false ); |
| 31 | + } |
| 32 | + $this->regex = $this->getCliArg( 'regex=' ); |
| 33 | + } else { |
| 34 | + # Matches anything |
| 35 | + $this->regex = ''; |
| 36 | + } |
| 37 | + |
| 38 | + $this->keepUploads = $this->getCliArg( 'keep-uploads' ); |
23 | 39 | |
| 40 | + |
| 41 | + |
24 | 42 | global $wgParser, $wgParserConf, $IP, $messageMemc, $wgMemc, $wgDeferredUpdateList, |
25 | 43 | $wgUser, $wgLang, $wgOut, $wgRequest, $wgStyleDirectory, $wgEnableParserCache, |
26 | 44 | $wgMessageCache, $wgUseDatabaseMessages, $wgMsgCacheExpiry, $parserMemc, |
— | — | @@ -66,6 +84,7 @@ |
67 | 85 | if ( $wgStyleDirectory === false ) { |
68 | 86 | $wgStyleDirectory = "$IP/skins"; |
69 | 87 | } |
| 88 | + |
70 | 89 | } |
71 | 90 | |
72 | 91 | /** |
— | — | @@ -273,12 +292,15 @@ |
274 | 293 | |
275 | 294 | public function testParserTests() { |
276 | 295 | |
277 | | - //global $IP; |
278 | | - //$wgParserTestFiles = array( "$IP/tests/parser/testparserTests.txt" ); |
279 | | - |
280 | 296 | global $wgParserTestFiles; |
281 | 297 | |
282 | | - foreach( $wgParserTestFiles as $file ) { |
| 298 | + $files = $wgParserTestFiles; |
| 299 | + |
| 300 | + if( $this->getCliArg( 'file=' ) ) { |
| 301 | + $files = array( $this->getCliArg( 'file=' ) ); |
| 302 | + } |
| 303 | + |
| 304 | + foreach( $files as $file ) { |
283 | 305 | |
284 | 306 | $iter = new ParserTestFileIterator( $file, $this ); |
285 | 307 | |