Merge "Add the required call to the parent setUp to DiffHistoryBlobTest::setUp()"
[lhc/web/wiklou.git] / tests / phpunit / includes / LinkerTest.php
1 <?php
2
3 class LinkerTest extends MediaWikiLangTestCase {
4
5 /**
6 * @dataProvider provideCasesForUserLink
7 * @cover Linker::userLink
8 */
9 function testUserLink( $expected, $userId, $userName, $altUserName = false, $msg='' ) {
10 $this->setMwGlobals( array(
11 'wgArticlePath' => '/wiki/$1',
12 ) );
13
14 $this->assertEquals( $expected,
15 Linker::userLink( $userId, $userName, $altUserName, $msg )
16 );
17 }
18
19 function provideCasesForUserLink() {
20 # Format:
21 # - expected
22 # - userid
23 # - username
24 # - optional altUserName
25 # - optional message
26 return array(
27
28 ### ANONYMOUS USER ########################################
29 array(
30 '<a href="/wiki/Special:Contributions/JohnDoe" title="Special:Contributions/JohnDoe" class="mw-userlink">JohnDoe</a>',
31 0, 'JohnDoe', false,
32 ),
33 array(
34 '<a href="/wiki/Special:Contributions/::1" title="Special:Contributions/::1" class="mw-userlink">::1</a>',
35 0, '::1', false,
36 'Anonymous with pretty IPv6'
37 ),
38 array(
39 '<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>',
40 0, '0:0:0:0:0:0:0:1', false,
41 'Anonymous with almost pretty IPv6'
42 ),
43 array(
44 '<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>',
45 0, '0000:0000:0000:0000:0000:0000:0000:0001', false,
46 'Anonymous with full IPv6'
47 ),
48 array(
49 '<a href="/wiki/Special:Contributions/::1" title="Special:Contributions/::1" class="mw-userlink">AlternativeUsername</a>',
50 0, '::1', 'AlternativeUsername',
51 'Anonymous with pretty IPv6 and an alternative username'
52 ),
53
54 # IPV4
55 array(
56 '<a href="/wiki/Special:Contributions/127.0.0.1" title="Special:Contributions/127.0.0.1" class="mw-userlink">127.0.0.1</a>',
57 0, '127.0.0.1', false,
58 'Anonymous with IPv4'
59 ),
60 array(
61 '<a href="/wiki/Special:Contributions/127.0.0.1" title="Special:Contributions/127.0.0.1" class="mw-userlink">AlternativeUsername</a>',
62 0, '127.0.0.1', 'AlternativeUsername',
63 'Anonymous with IPv4 and an alternative username'
64 ),
65
66 ### Regular user ##########################################
67 # TODO!
68 );
69 }
70 }