7 class WikiMapTest
extends MediaWikiLangTestCase
{
9 public function setUp() {
12 $conf = new SiteConfiguration();
13 $conf->settings
= array(
15 'enwiki' => 'http://en.example.org',
16 'ruwiki' => '//ru.example.org',
18 'wgArticlePath' => array(
20 'ruwiki' => '/wiki/$1',
23 $conf->suffixes
= array( 'wiki' );
24 $this->setMwGlobals( array(
29 public function provideGetWiki() {
30 $enwiki = new WikiReference( 'wiki', 'en', 'http://en.example.org', '/w/$1' );
31 $ruwiki = new WikiReference( 'wiki', 'ru', '//ru.example.org', '/wiki/$1' );
34 'unknown' => array( false, 'xyzzy' ),
35 'enwiki' => array( $enwiki, 'enwiki' ),
36 'ruwiki' => array( $ruwiki, 'ruwiki' ),
41 * @dataProvider provideGetWiki
43 public function testGetWiki( $expected, $wikiId ) {
44 $this->assertEquals( $expected, WikiMap
::getWiki( $wikiId ) );
47 public function provideGetWikiName() {
49 'unknown' => array( 'xyzzy', 'xyzzy' ),
50 'enwiki' => array( 'en.example.org', 'enwiki' ),
51 'ruwiki' => array( 'ru.example.org', 'ruwiki' ),
56 * @dataProvider provideGetWikiName
58 public function testGetWikiName( $expected, $wikiId ) {
59 $this->assertEquals( $expected, WikiMap
::getWikiName( $wikiId ) );
62 public function provideMakeForeignLink() {
64 'unknown' => array( false, 'xyzzy', 'Foo' ),
65 'enwiki' => array( '<a class="external" rel="nofollow" href="http://en.example.org/w/Foo">Foo</a>', 'enwiki', 'Foo' ),
66 'ruwiki' => array( '<a class="external" rel="nofollow" href="//ru.example.org/wiki/%D0%A4%D1%83">вар</a>', 'ruwiki', 'Фу', 'вар' ),
71 * @dataProvider provideMakeForeignLink
73 public function testMakeForeignLink( $expected, $wikiId, $page, $text = null ) {
74 $this->assertEquals( $expected, WikiMap
::makeForeignLink( $wikiId, $page, $text ) );
77 public function provideForeignUserLink() {
79 'unknown' => array( false, 'xyzzy', 'Foo' ),
80 'enwiki' => array( '<a class="external" rel="nofollow" href="http://en.example.org/w/User:Foo">User:Foo</a>', 'enwiki', 'Foo' ),
81 'ruwiki' => array( '<a class="external" rel="nofollow" href="//ru.example.org/wiki/User:%D0%A4%D1%83">вар</a>', 'ruwiki', 'Фу', 'вар' ),
86 * @dataProvider provideForeignUserLink
88 public function testForeignUserLink( $expected, $wikiId, $user, $text = null ) {
89 $this->assertEquals( $expected, WikiMap
::foreignUserLink( $wikiId, $user, $text ) );
92 public function provideGetForeignURL() {
94 'unknown' => array( false, 'xyzzy', 'Foo' ),
95 'enwiki' => array( 'http://en.example.org/w/Foo', 'enwiki', 'Foo' ),
96 'ruwiki with fragement' => array( '//ru.example.org/wiki/%D0%A4%D1%83#%D0%B2%D0%B0%D1%80', 'ruwiki', 'Фу', 'вар' ),
101 * @dataProvider provideGetForeignURL
103 public function testGetForeignURL( $expected, $wikiId, $page, $fragment = null ) {
104 $this->assertEquals( $expected, WikiMap
::getForeignURL( $wikiId, $page, $fragment ) );