2022-06-21 19:28:52 +00:00
|
|
|
<?php
|
|
|
|
|
|
2022-09-09 20:18:22 +00:00
|
|
|
use MediaWiki\MainConfigNames;
|
|
|
|
|
|
2022-06-21 19:28:52 +00:00
|
|
|
/**
|
|
|
|
|
* @group ContentHandler
|
|
|
|
|
* @group Database
|
|
|
|
|
* ^--- needed, because we do need the database to test link updates
|
|
|
|
|
*/
|
|
|
|
|
class WikitextContentHandlerIntegrationTest extends TextContentHandlerIntegrationTest {
|
|
|
|
|
public static function provideGetParserOutput() {
|
|
|
|
|
yield 'Basic render' => [
|
|
|
|
|
'title' => 'WikitextContentTest_testGetParserOutput',
|
|
|
|
|
'model' => CONTENT_MODEL_WIKITEXT,
|
|
|
|
|
'text' => "hello ''world''\n",
|
|
|
|
|
'expectedHtml' => "<div class=\"mw-parser-output\"><p>hello <i>world</i>\n</p></div>",
|
|
|
|
|
'expectedFields' => [
|
|
|
|
|
'Links' => [
|
|
|
|
|
],
|
|
|
|
|
'Sections' => [
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
yield 'Links' => [
|
|
|
|
|
'title' => 'WikitextContentTest_testGetParserOutput',
|
|
|
|
|
'model' => CONTENT_MODEL_WIKITEXT,
|
|
|
|
|
'text' => "[[title that does not really exist]]",
|
|
|
|
|
'expectedHtml' => null,
|
|
|
|
|
'expectedFields' => [
|
|
|
|
|
'Links' => [
|
|
|
|
|
[ 'Title_that_does_not_really_exist' => 0, ],
|
|
|
|
|
],
|
|
|
|
|
'Sections' => [
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
yield 'TOC' => [
|
|
|
|
|
'title' => 'WikitextContentTest_testGetParserOutput',
|
|
|
|
|
'model' => CONTENT_MODEL_WIKITEXT,
|
2022-09-09 20:18:22 +00:00
|
|
|
'text' => "==One==\n==Two==\n==Three==\n==Four==\n<h2>Five</h2>\n===Six+Seven %2525===",
|
2022-06-21 19:28:52 +00:00
|
|
|
'expectedHtml' => null,
|
|
|
|
|
'expectedFields' => [
|
|
|
|
|
'Links' => [
|
|
|
|
|
],
|
|
|
|
|
'Sections' => [
|
|
|
|
|
[
|
|
|
|
|
'toclevel' => 1,
|
|
|
|
|
'level' => '2',
|
|
|
|
|
'line' => 'One',
|
|
|
|
|
'number' => '1',
|
|
|
|
|
'index' => '1',
|
|
|
|
|
'fromtitle' => 'WikitextContentTest_testGetParserOutput',
|
|
|
|
|
'byteoffset' => 0,
|
|
|
|
|
'anchor' => 'One',
|
2022-09-09 20:18:22 +00:00
|
|
|
'linkAnchor' => 'One',
|
2022-06-21 19:28:52 +00:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'toclevel' => 1,
|
|
|
|
|
'level' => '2',
|
|
|
|
|
'line' => 'Two',
|
|
|
|
|
'number' => '2',
|
|
|
|
|
'index' => '2',
|
|
|
|
|
'fromtitle' => 'WikitextContentTest_testGetParserOutput',
|
|
|
|
|
'byteoffset' => 8,
|
|
|
|
|
'anchor' => 'Two',
|
2022-09-09 20:18:22 +00:00
|
|
|
'linkAnchor' => 'Two',
|
2022-06-21 19:28:52 +00:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'toclevel' => 1,
|
|
|
|
|
'level' => '2',
|
|
|
|
|
'line' => 'Three',
|
|
|
|
|
'number' => '3',
|
|
|
|
|
'index' => '3',
|
|
|
|
|
'fromtitle' => 'WikitextContentTest_testGetParserOutput',
|
|
|
|
|
'byteoffset' => 16,
|
|
|
|
|
'anchor' => 'Three',
|
2022-09-09 20:18:22 +00:00
|
|
|
'linkAnchor' => 'Three',
|
2022-06-21 19:28:52 +00:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'toclevel' => 1,
|
|
|
|
|
'level' => '2',
|
|
|
|
|
'line' => 'Four',
|
|
|
|
|
'number' => '4',
|
|
|
|
|
'index' => '4',
|
|
|
|
|
'fromtitle' => 'WikitextContentTest_testGetParserOutput',
|
|
|
|
|
'byteoffset' => 26,
|
|
|
|
|
'anchor' => 'Four',
|
2022-09-09 20:18:22 +00:00
|
|
|
'linkAnchor' => 'Four',
|
2022-06-21 19:28:52 +00:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'toclevel' => 1,
|
|
|
|
|
'level' => '2',
|
|
|
|
|
'line' => 'Five',
|
|
|
|
|
'number' => '5',
|
|
|
|
|
'index' => '',
|
|
|
|
|
'fromtitle' => false,
|
|
|
|
|
'byteoffset' => null,
|
|
|
|
|
'anchor' => 'Five',
|
2022-09-09 20:18:22 +00:00
|
|
|
'linkAnchor' => 'Five',
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'toclevel' => 2,
|
|
|
|
|
'level' => '3',
|
|
|
|
|
'line' => 'Six+Seven %2525',
|
|
|
|
|
'number' => '5.1',
|
|
|
|
|
'index' => '5',
|
|
|
|
|
'fromtitle' => 'WikitextContentTest_testGetParserOutput',
|
|
|
|
|
'byteoffset' => 49,
|
|
|
|
|
'anchor' => 'Six+Seven_%2525',
|
|
|
|
|
'linkAnchor' => 'Six+Seven_%252525',
|
2022-06-21 19:28:52 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
}
|
2022-09-09 20:18:22 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @dataProvider provideGetParserOutput
|
|
|
|
|
* @covers WikitextContentHandler::fillParserOutput
|
|
|
|
|
*/
|
|
|
|
|
public function testGetParserOutput( $title, $model, $text, $expectedHtml,
|
|
|
|
|
$expectedFields = null
|
|
|
|
|
) {
|
|
|
|
|
$this->overrideConfigValue( MainConfigNames::FragmentMode, [ 'html5' ] );
|
|
|
|
|
parent::testGetParserOutput(
|
|
|
|
|
$title, $model, $text, $expectedHtml, $expectedFields
|
|
|
|
|
);
|
|
|
|
|
}
|
2022-06-21 19:28:52 +00:00
|
|
|
}
|