| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Tests\Maintenance; |
| 4 |
|
| 5 |
use CLIParser; |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
class CLIParserTest extends MaintenanceBaseTestCase { |
| 13 |
|
| 14 |
protected function getMaintenanceClass() { |
| 15 |
return CLIParser::class; |
| 16 |
} |
| 17 |
|
| 18 |
|
| 19 |
public function testExecute( $inputWikitext, $options, $expectedOutput ) { |
| 20 |
foreach ( $options as $name => $value ) { |
| 21 |
$this->maintenance->setOption( $name, $value ); |
| 22 |
} |
| 23 |
|
| 24 |
|
| 25 |
$testFilename = $this->getNewTempFile(); |
| 26 |
$testFile = fopen( $testFilename, 'w' ); |
| 27 |
fwrite( $testFile, $inputWikitext ); |
| 28 |
fclose( $testFile ); |
| 29 |
$this->maintenance->setArg( 'file', $testFilename ); |
| 30 |
|
| 31 |
$this->maintenance->execute(); |
| 32 |
$this->expectOutputString( $expectedOutput ); |
| 33 |
} |
| 34 |
|
| 35 |
public static function provideExecute() { |
| 36 |
return [ |
| 37 |
'No wikitext in the content' => [ 'testing1234', [], "<p>testing1234\n</p>" ], |
| 38 |
'Wikitext in the content' => [ '* testing1234', [], '<ul><li>testing1234</li></ul>' ], |
| 39 |
]; |
| 40 |
} |
| 41 |
} |