X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FLinkerTest.php;h=823c9330a664e80bcf6b9e96305cc2a2c2129dd4;hb=1d0aeec98f1953b4e30e85c5c423e3ca8c724483;hp=fc88a550cd280c71468d2748c3758ce4c2b2f41c;hpb=4ab52fb8ecd475bbb088c3b48bb0ba12b8dbd95b;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/LinkerTest.php b/tests/phpunit/includes/LinkerTest.php index fc88a550cd..823c9330a6 100644 --- a/tests/phpunit/includes/LinkerTest.php +++ b/tests/phpunit/includes/LinkerTest.php @@ -193,4 +193,54 @@ class LinkerTest extends MediaWikiLangTestCase { ), ); } + + /** + * @covers Linker::formatLinksInComment + * @dataProvider provideCasesForFormatLinksInComment + */ + public function testFormatLinksInComment( $expected, $input, $wiki ) { + + $conf = new SiteConfiguration(); + $conf->settings = array( + 'wgServer' => array( + 'enwiki' => '//en.example.org' + ), + 'wgArticlePath' => array( + 'enwiki' => '/w/$1', + ), + ); + $conf->suffixes = array( 'wiki' ); + $this->setMwGlobals( array( + 'wgScript' => '/wiki/index.php', + 'wgArticlePath' => '/wiki/$1', + 'wgWellFormedXml' => true, + 'wgCapitalLinks' => true, + 'wgConf' => $conf, + ) ); + + $this->assertEquals( + $expected, + Linker::formatLinksInComment( $input, Title::newFromText( 'Special:BlankPage' ), false, $wiki ) + ); + } + + public static function provideCasesForFormatLinksInComment() { + return array( + array( + 'foo bar Special:BlankPage', + 'foo bar [[Special:BlankPage]]', + null, + ), + array( + 'Foo\'bar', + "[[Foo'bar]]", + 'enwiki', + ), + array( + 'foo bar Special:BlankPage', + 'foo bar [[Special:BlankPage]]', + 'enwiki', + ), + ); + } }