X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Finterwiki%2FClassicInterwikiLookupTest.php;h=48310a9f41df528644df946ef8cd6e17c14ad583;hb=5468aecf3e62649322a1e76dda2414e7821af864;hp=db6d00295c1c1c01114462245f29bb7d01b84b55;hpb=eaae000bd6a9ba542ed2fb3d0f9a8d78be3a8db6;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/interwiki/ClassicInterwikiLookupTest.php b/tests/phpunit/includes/interwiki/ClassicInterwikiLookupTest.php index db6d00295c..48310a9f41 100644 --- a/tests/phpunit/includes/interwiki/ClassicInterwikiLookupTest.php +++ b/tests/phpunit/includes/interwiki/ClassicInterwikiLookupTest.php @@ -133,18 +133,18 @@ class ClassicInterwikiLookupTest extends MediaWikiTestCase { // NOTE: CDB setup is expensive, so we only do // it once and run all the tests in one go. - $dewiki = [ - 'iw_prefix' => 'de', - 'iw_url' => 'http://de.wikipedia.org/wiki/', - 'iw_local' => 1 - ]; - $zzwiki = [ 'iw_prefix' => 'zz', 'iw_url' => 'http://zzwiki.org/wiki/', 'iw_local' => 0 ]; + $dewiki = [ + 'iw_prefix' => 'de', + 'iw_url' => 'http://de.wikipedia.org/wiki/', + 'iw_local' => 1 + ]; + $cdbFile = $this->populateCDB( 'en', [ $dewiki ], @@ -160,7 +160,7 @@ class ClassicInterwikiLookupTest extends MediaWikiTestCase { ); $this->assertEquals( - [ $dewiki, $zzwiki ], + [ $zzwiki, $dewiki ], $lookup->getAllPrefixes(), 'getAllPrefixes()' ); @@ -185,17 +185,16 @@ class ClassicInterwikiLookupTest extends MediaWikiTestCase { } public function testArrayStorage() { - $dewiki = [ - 'iw_prefix' => 'de', - 'iw_url' => 'http://de.wikipedia.org/wiki/', - 'iw_local' => 1 - ]; - $zzwiki = [ 'iw_prefix' => 'zz', 'iw_url' => 'http://zzwiki.org/wiki/', 'iw_local' => 0 ]; + $dewiki = [ + 'iw_prefix' => 'de', + 'iw_url' => 'http://de.wikipedia.org/wiki/', + 'iw_local' => 1 + ]; $hash = $this->populateHash( 'en', @@ -212,7 +211,7 @@ class ClassicInterwikiLookupTest extends MediaWikiTestCase { ); $this->assertEquals( - [ $dewiki, $zzwiki ], + [ $zzwiki, $dewiki ], $lookup->getAllPrefixes(), 'getAllPrefixes()' ); @@ -233,4 +232,42 @@ class ClassicInterwikiLookupTest extends MediaWikiTestCase { $this->assertSame( false, $interwiki->isLocal(), 'isLocal' ); } + public function testGetAllPrefixes() { + $zz = [ + 'iw_prefix' => 'zz', + 'iw_url' => 'https://azz.example.org/', + 'iw_local' => 1 + ]; + $de = [ + 'iw_prefix' => 'de', + 'iw_url' => 'https://de.example.org/', + 'iw_local' => 1 + ]; + $azz = [ + 'iw_prefix' => 'azz', + 'iw_url' => 'https://azz.example.org/', + 'iw_local' => 1 + ]; + + $hash = $this->populateHash( + 'en', + [], + [ $zz, $de, $azz ] + ); + $lookup = new \MediaWiki\Interwiki\ClassicInterwikiLookup( + Language::factory( 'en' ), + WANObjectCache::newEmpty(), + 60 * 60, + $hash, + 3, + 'en' + ); + + $this->assertEquals( + [ $zz, $de, $azz ], + $lookup->getAllPrefixes(), + 'getAllPrefixes() - preserves order' + ); + } + }