Debian Codegraph @

tests/phpunit/maintenance/CLIParserTest.php

raw symbols SCIP
1 <?php
2
3 namespace MediaWiki\Tests\Maintenance;
4
5 use CLIParser;
6
7 /**
8 * @covers \CLIParser
9 * @group Database
10 * @author Dreamy Jazz
11 */
12 class CLIParserTest extends MaintenanceBaseTestCase {
13
14 protected function getMaintenanceClass() {
15 return CLIParser::class;
16 }
17
18 /** @dataProvider provideExecute */
19 public function testExecute( $inputWikitext, $options, $expectedOutput ) {
20 foreach ( $options as $name => $value ) {
21 $this->maintenance->setOption( $name, $value );
22 }
23 // Get a file with the input wikitext as the content of the file and pass the filename
24 // to the maintenance script
25 $testFilename = $this->getNewTempFile();
26 $testFile = fopen( $testFilename, 'w' );
27 fwrite( $testFile, $inputWikitext );
28 fclose( $testFile );
29 $this->maintenance->setArg( 'file', $testFilename );
30 // Run the maintenance script and expect that the output is the expected HTML
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 }