X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fcache%2FLocalisationCacheTest.php;h=39526fb9c738055fbd9524ac9059675d2e0eaf20;hb=a158a4fb32b57027f0dece321e4c18af4687454d;hp=ed821530a2b5b90219ebc587c6f7a993b0aa4e76;hpb=c2a681ba58c8718242d39450c34a603346126b98;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/cache/LocalisationCacheTest.php b/tests/phpunit/includes/cache/LocalisationCacheTest.php index ed821530a2..39526fb9c7 100644 --- a/tests/phpunit/includes/cache/LocalisationCacheTest.php +++ b/tests/phpunit/includes/cache/LocalisationCacheTest.php @@ -1,4 +1,9 @@ getMockBuilder( 'LocalisationCache' ) - ->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::$constructorOptions, [ + '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( @@ -75,7 +123,7 @@ class LocalisationCacheTest extends MediaWikiTestCase { public function testRecacheFallbacksWithHooks() { // Use hook to provide updates for messages. This is what the - // LocalisationUpdate extension does. See bug 68781. + // LocalisationUpdate extension does. See T70781. $this->mergeMwGlobalArrayValue( 'wgHooks', [ 'LocalisationCacheRecacheFallback' => [ function (