X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fcache%2FLocalisationCacheTest.php;h=4dd819a61b86ad3075ed70ef566732187dba4121;hb=e3537bdc00244cefdaa34710be0fb0d920336ed8;hp=42957b6084318979b484cfc489efbb7bed2bace3;hpb=15f6eff90c305d405fe4331c8a8dc8caa842e5b3;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/cache/LocalisationCacheTest.php b/tests/phpunit/includes/cache/LocalisationCacheTest.php index 42957b6084..4dd819a61b 100644 --- a/tests/phpunit/includes/cache/LocalisationCacheTest.php +++ b/tests/phpunit/includes/cache/LocalisationCacheTest.php @@ -1,4 +1,9 @@ getMockBuilder( \LocalisationCache::class ) - ->setConstructorArgs( [ [ 'store' => 'detect' ] ] ) + + $mockLangNameUtils = $this->createMock( LanguageNameUtils::class ); + $mockLangNameUtils->method( 'isValidBuiltInCode' )->will( $this->returnCallback( + function ( $code ) { + // Copy-paste, but it's only one line + return (bool)preg_match( '/^[a-z0-9-]{2,}$/', $code ); + } + ) ); + $mockLangNameUtils->method( 'isSupportedLanguage' )->will( $this->returnCallback( + function ( $code ) { + return in_array( $code, [ + 'ar', + 'arz', + 'ba', + 'de', + 'en', + 'ksh', + 'ru', + ] ); + } + ) ); + $mockLangNameUtils->method( 'getMessagesFileName' )->will( $this->returnCallback( + function ( $code ) { + global $IP; + $code = str_replace( '-', '_', ucfirst( $code ) ); + return "$IP/languages/messages/Messages$code.php"; + } + ) ); + $mockLangNameUtils->expects( $this->never() )->method( $this->anythingBut( + 'isValidBuiltInCode', 'isSupportedLanguage', 'getMessagesFileName' + ) ); + + $lc = $this->getMockBuilder( LocalisationCache::class ) + ->setConstructorArgs( [ + new ServiceOptions( LocalisationCache::CONSTRUCTOR_OPTIONS, [ + 'forceRecache' => false, + 'manualRecache' => false, + 'ExtensionMessagesFiles' => [], + 'MessagesDirs' => [], + ] ), + new LCStoreDB( [] ), + new NullLogger, + [], + $mockLangNameUtils + ] ) ->setMethods( [ 'getMessagesDirs' ] ) ->getMock(); $lc->expects( $this->any() )->method( 'getMessagesDirs' ) @@ -31,7 +79,7 @@ class LocalisationCacheTest extends MediaWikiTestCase { return $lc; } - public function testPuralRulesFallback() { + public function testPluralRulesFallback() { $cache = $this->getMockLocalisationCache(); $this->assertEquals(