MediaWiki  REL1_22
LinkerTest.php
Go to the documentation of this file.
00001 <?php
00002 
00003 class LinkerTest extends MediaWikiLangTestCase {
00004 
00009     public function testUserLink( $expected, $userId, $userName, $altUserName = false, $msg = '' ) {
00010         $this->setMwGlobals( array(
00011             'wgArticlePath' => '/wiki/$1',
00012             'wgWellFormedXml' => true,
00013         ) );
00014 
00015         $this->assertEquals( $expected,
00016             Linker::userLink( $userId, $userName, $altUserName, $msg )
00017         );
00018     }
00019 
00020     public static function provideCasesForUserLink() {
00021         # Format:
00022         # - expected
00023         # - userid
00024         # - username
00025         # - optional altUserName
00026         # - optional message
00027         return array(
00028 
00029             ### ANONYMOUS USER ########################################
00030             array(
00031                 '<a href="/wiki/Special:Contributions/JohnDoe" title="Special:Contributions/JohnDoe" class="mw-userlink">JohnDoe</a>',
00032                 0, 'JohnDoe', false,
00033             ),
00034             array(
00035                 '<a href="/wiki/Special:Contributions/::1" title="Special:Contributions/::1" class="mw-userlink">::1</a>',
00036                 0, '::1', false,
00037                 'Anonymous with pretty IPv6'
00038             ),
00039             array(
00040                 '<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>',
00041                 0, '0:0:0:0:0:0:0:1', false,
00042                 'Anonymous with almost pretty IPv6'
00043             ),
00044             array(
00045                 '<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>',
00046                 0, '0000:0000:0000:0000:0000:0000:0000:0001', false,
00047                 'Anonymous with full IPv6'
00048             ),
00049             array(
00050                 '<a href="/wiki/Special:Contributions/::1" title="Special:Contributions/::1" class="mw-userlink">AlternativeUsername</a>',
00051                 0, '::1', 'AlternativeUsername',
00052                 'Anonymous with pretty IPv6 and an alternative username'
00053             ),
00054 
00055             # IPV4
00056             array(
00057                 '<a href="/wiki/Special:Contributions/127.0.0.1" title="Special:Contributions/127.0.0.1" class="mw-userlink">127.0.0.1</a>',
00058                 0, '127.0.0.1', false,
00059                 'Anonymous with IPv4'
00060             ),
00061             array(
00062                 '<a href="/wiki/Special:Contributions/127.0.0.1" title="Special:Contributions/127.0.0.1" class="mw-userlink">AlternativeUsername</a>',
00063                 0, '127.0.0.1', 'AlternativeUsername',
00064                 'Anonymous with IPv4 and an alternative username'
00065             ),
00066 
00067             ### Regular user ##########################################
00068             # TODO!
00069         );
00070     }
00071 }