diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2013-09-04 05:51:59 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2013-09-04 05:51:59 +0200 |
commit | 91e194556c52d2f354344f930419eef2dd6267f0 (patch) | |
tree | 0cd12490d3cd3499274017c9b799d0f738d3719e /tests/phpunit/includes/LinkerTest.php | |
parent | 08aa4418c30cfc18ccc69a0f0f9cb9e17be6c196 (diff) |
Update to MediaWiki 1.21.2
Diffstat (limited to 'tests/phpunit/includes/LinkerTest.php')
-rw-r--r-- | tests/phpunit/includes/LinkerTest.php | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/tests/phpunit/includes/LinkerTest.php b/tests/phpunit/includes/LinkerTest.php new file mode 100644 index 00000000..e353c46c --- /dev/null +++ b/tests/phpunit/includes/LinkerTest.php @@ -0,0 +1,71 @@ +<?php + +class LinkerTest extends MediaWikiLangTestCase { + + /** + * @dataProvider provideCasesForUserLink + * @covers Linker::userLink + */ + function testUserLink( $expected, $userId, $userName, $altUserName = false, $msg = '' ) { + $this->setMwGlobals( array( + 'wgArticlePath' => '/wiki/$1', + 'wgWellFormedXml' => true, + ) ); + + $this->assertEquals( $expected, + Linker::userLink( $userId, $userName, $altUserName, $msg ) + ); + } + + function provideCasesForUserLink() { + # Format: + # - expected + # - userid + # - username + # - optional altUserName + # - optional message + return array( + + ### ANONYMOUS USER ######################################## + array( + '<a href="/wiki/Special:Contributions/JohnDoe" title="Special:Contributions/JohnDoe" class="mw-userlink">JohnDoe</a>', + 0, 'JohnDoe', false, + ), + array( + '<a href="/wiki/Special:Contributions/::1" title="Special:Contributions/::1" class="mw-userlink">::1</a>', + 0, '::1', false, + 'Anonymous with pretty IPv6' + ), + array( + '<a href="/wiki/Special:Contributions/0:0:0:0:0:0:0:1" title="Special:Contributions/0:0:0:0:0:0:0:1" class="mw-userlink">::1</a>', + 0, '0:0:0:0:0:0:0:1', false, + 'Anonymous with almost pretty IPv6' + ), + array( + '<a href="/wiki/Special:Contributions/0000:0000:0000:0000:0000:0000:0000:0001" title="Special:Contributions/0000:0000:0000:0000:0000:0000:0000:0001" class="mw-userlink">::1</a>', + 0, '0000:0000:0000:0000:0000:0000:0000:0001', false, + 'Anonymous with full IPv6' + ), + array( + '<a href="/wiki/Special:Contributions/::1" title="Special:Contributions/::1" class="mw-userlink">AlternativeUsername</a>', + 0, '::1', 'AlternativeUsername', + 'Anonymous with pretty IPv6 and an alternative username' + ), + + # IPV4 + array( + '<a href="/wiki/Special:Contributions/127.0.0.1" title="Special:Contributions/127.0.0.1" class="mw-userlink">127.0.0.1</a>', + 0, '127.0.0.1', false, + 'Anonymous with IPv4' + ), + array( + '<a href="/wiki/Special:Contributions/127.0.0.1" title="Special:Contributions/127.0.0.1" class="mw-userlink">AlternativeUsername</a>', + 0, '127.0.0.1', 'AlternativeUsername', + 'Anonymous with IPv4 and an alternative username' + ), + + ### Regular user ########################################## + # TODO! + ); + } +} |