From 14f74d141ab5580688bfd46d2f74c026e43ed967 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 1 Apr 2015 06:11:44 +0200 Subject: Update to MediaWiki 1.24.2 --- tests/phpunit/includes/LinkerTest.php | 192 ++++++++++++++++++++++++++++++++++ 1 file changed, 192 insertions(+) create mode 100644 tests/phpunit/includes/LinkerTest.php (limited to 'tests/phpunit/includes/LinkerTest.php') diff --git a/tests/phpunit/includes/LinkerTest.php b/tests/phpunit/includes/LinkerTest.php new file mode 100644 index 00000000..7b84107e --- /dev/null +++ b/tests/phpunit/includes/LinkerTest.php @@ -0,0 +1,192 @@ +setMwGlobals( array( + 'wgArticlePath' => '/wiki/$1', + 'wgWellFormedXml' => true, + ) ); + + $this->assertEquals( $expected, + Linker::userLink( $userId, $userName, $altUserName, $msg ) + ); + } + + public static function provideCasesForUserLink() { + # Format: + # - expected + # - userid + # - username + # - optional altUserName + # - optional message + return array( + + ### ANONYMOUS USER ######################################## + array( + 'JohnDoe', + 0, 'JohnDoe', false, + ), + array( + '::1', + 0, '::1', false, + 'Anonymous with pretty IPv6' + ), + array( + '::1', + 0, '0:0:0:0:0:0:0:1', false, + 'Anonymous with almost pretty IPv6' + ), + array( + '::1', + 0, '0000:0000:0000:0000:0000:0000:0000:0001', false, + 'Anonymous with full IPv6' + ), + array( + 'AlternativeUsername', + 0, '::1', 'AlternativeUsername', + 'Anonymous with pretty IPv6 and an alternative username' + ), + + # IPV4 + array( + '127.0.0.1', + 0, '127.0.0.1', false, + 'Anonymous with IPv4' + ), + array( + 'AlternativeUsername', + 0, '127.0.0.1', 'AlternativeUsername', + 'Anonymous with IPv4 and an alternative username' + ), + + ### Regular user ########################################## + # TODO! + ); + } + + /** + * @dataProvider provideCasesForFormatComment + * @covers Linker::formatComment + * @covers Linker::formatAutocomments + * @covers Linker::formatLinksInComment + */ + public function testFormatComment( $expected, $comment, $title = false, $local = false ) { + $this->setMwGlobals( array( + 'wgScript' => '/wiki/index.php', + 'wgArticlePath' => '/wiki/$1', + 'wgWellFormedXml' => true, + 'wgCapitalLinks' => 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