X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FLinkerTest.php;h=9889b0863ee0f62a8e1e1ac263d31722a5e9905a;hb=5cb425a62b6eba0161702fe49568d137d7b91c91;hp=351ad344330af6e8a2789da3490d84be72f421ab;hpb=4114333da508a12e3d806345475534fb10aa871c;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/LinkerTest.php b/tests/phpunit/includes/LinkerTest.php index 351ad34433..9889b0863e 100644 --- a/tests/phpunit/includes/LinkerTest.php +++ b/tests/phpunit/includes/LinkerTest.php @@ -28,38 +28,52 @@ class LinkerTest extends MediaWikiLangTestCase { ### ANONYMOUS USER ######################################## array( - 'JohnDoe', + 'JohnDoe', 0, 'JohnDoe', false, ), array( - '::1', + '::1', 0, '::1', false, 'Anonymous with pretty IPv6' ), array( - '::1', + '::1', 0, '0:0:0:0:0:0:0:1', false, 'Anonymous with almost pretty IPv6' ), array( - '::1', + '::1', 0, '0000:0000:0000:0000:0000:0000:0000:0001', false, 'Anonymous with full IPv6' ), array( - 'AlternativeUsername', + 'AlternativeUsername', 0, '::1', 'AlternativeUsername', 'Anonymous with pretty IPv6 and an alternative username' ), # IPV4 array( - '127.0.0.1', + '127.0.0.1', 0, '127.0.0.1', false, 'Anonymous with IPv4' ), array( - 'AlternativeUsername', + 'AlternativeUsername', 0, '127.0.0.1', 'AlternativeUsername', 'Anonymous with IPv4 and an alternative username' ), @@ -68,4 +82,105 @@ class LinkerTest extends MediaWikiLangTestCase { # TODO! ); } + + /** + * @dataProvider provideCasesForFormatComment + * @covers Linker::formatComment + * @covers Linker::formatAutocomments + * @covers Linker::formatLinksInComment + */ + public function testFormatComment( $expected, $comment, $title = false, $local = false ) { + $this->setMwGlobals( array( + 'wgArticlePath' => '/wiki/$1', + 'wgWellFormedXml' => true, + ) ); + + if ( $title === false ) { + // We need a page title that exists + $title = Title::newFromText( 'Special:BlankPage' ); + } + + $this->assertEquals( + $expected, + Linker::formatComment( $comment, $title, $local ) + ); + } + + public static function provideCasesForFormatComment() { + return array( + // Linker::formatComment + array( + 'a<script>b', + 'a