}
private function makeLegacyAnchor( $sectionName ) {
- $fragmentMode = $this->config->get( 'FragmentMode' );
+ $fragmentMode = $this->siteConfig->get( 'FragmentMode' );
if ( isset( $fragmentMode[1] ) && $fragmentMode[1] === 'legacy' ) {
// ForAttribute() and ForLink() are the same for legacy encoding
$id = Sanitizer::escapeIdForAttribute( $sectionName, Sanitizer::ID_FALLBACK );
}
}
+ public static function provideGuessSectionNameFromWikiText() {
+ return [
+ [ '1/2', 'html5', '#1/2' ],
+ [ '1/2', 'legacy', '#1.2F2' ],
+ ];
+ }
+
+ /** @dataProvider provideGuessSectionNameFromWikiText */
+ public function testGuessSectionNameFromWikiText( $input, $mode, $expected ) {
+ $this->setMwGlobals( [ 'wgFragmentMode' => [ $mode ] ] );
+ global $wgParser;
+ $result = $wgParser->guessSectionNameFromWikiText( $input );
+ $this->assertEquals( $result, $expected );
+ }
+
// @todo Add tests for cleanSig() / cleanSigInSig(), getSection(),
// replaceSection(), getPreloadText()
}