overrideConfigValues( [
MainConfigNames::ArticlePath => '/wiki/$1',
MainConfigNames::ScriptPath => '/w',
MainConfigNames::Script => '/w/index.php',
] );
$po = new ParserOutput( $text );
self::initSections( $po );
$actual = $this->getServiceContainer()->getDefaultOutputTransform()->transform( $po, $options )
->getTransformedText();
$this->assertSame( $expect, $actual );
}
private static function initSections( ParserOutput $po ): void {
$po->setTOCData( new TOCData(
SectionMetadata::fromLegacy( [
'index' => "1",
'level' => 1,
'toclevel' => 1,
'number' => "1",
'line' => "Section 1",
'anchor' => "Section_1"
] ),
SectionMetadata::fromLegacy( [
'index' => "2",
'level' => 1,
'toclevel' => 1,
'number' => "2",
'line' => "Section 2",
'anchor' => "Section_2"
] ),
SectionMetadata::fromLegacy( [
'index' => "3",
'level' => 2,
'toclevel' => 2,
'number' => "2.1",
'line' => "Section 2.1",
'anchor' => "Section_2.1"
] ),
SectionMetadata::fromLegacy( [
'index' => "4",
'level' => 1,
'toclevel' => 1,
'number' => "3",
'line' => "Section 3",
'anchor' => "Section_3"
] ),
) );
}
public static function provideTransform() {
$text = <<
One
Two
Two point one
Three
EOF; $dedupText = <<One
Two
Two point one
Three
EOF ], 'Disable section edit links' => [ [ 'enableSectionEditLinks' => false ], $text, <<One
Two
Two point one
Three
EOF ], 'Disable TOC, but wrap' => [ [ 'allowTOC' => false, 'wrapperDivClass' => 'mw-parser-output' ], $text, <<Test document.
One
Two
Two point one
Three
EOF ], 'Style deduplication' => [ [], $dedupText, <<test
', 'expectedText' => 'test
', ]; yield 'simple link' => [ 'text' => 'test', 'expectedText' => 'test', ]; yield 'already absolute, relative' => [ 'text' => 'test', 'expectedText' => 'test', ]; yield 'already absolute, https' => [ 'text' => 'test', 'expectedText' => 'test', ]; yield 'external' => [ 'text' => 'test', 'expectedText' => 'test', ]; } /** * @covers \Mediawiki\ParserOutputTransform\DefaultOutputTransform::transform * @dataProvider provideTransform_absoluteURLs */ public function testTransform_absoluteURLs( string $text, string $expectedText ) { $this->overrideConfigValue( MainConfigNames::Server, '//TEST_SERVER' ); $po = new ParserOutput( $text ); $actual = $this->getServiceContainer()->getDefaultOutputTransform() ->transform( $po, [ 'absoluteURLs' => true ] )->getTransformedText(); $this->assertSame( $expectedText, $actual ); } }