Services: Convert LocalisationCache's static to a const now HHVM is gone
[lhc/web/wiklou.git] / tests / phpunit / includes / cache / LocalisationCacheTest.php
index 697eb2d..af1ff86 100644 (file)
@@ -1,4 +1,8 @@
 <?php
+
+use MediaWiki\Config\ServiceOptions;
+use Psr\Log\NullLogger;
+
 /**
  * @group Database
  * @group Cache
@@ -19,8 +23,18 @@ class LocalisationCacheTest extends MediaWikiTestCase {
         */
        protected function getMockLocalisationCache() {
                global $IP;
-               $lc = $this->getMockBuilder( 'LocalisationCache' )
-                       ->setConstructorArgs( [ [ 'store' => 'detect' ] ] )
+
+               $lc = $this->getMockBuilder( LocalisationCache::class )
+                       ->setConstructorArgs( [
+                               new ServiceOptions( LocalisationCache::CONSTRUCTOR_OPTIONS, [
+                                       'forceRecache' => false,
+                                       'manualRecache' => false,
+                                       'ExtensionMessagesFiles' => [],
+                                       'MessagesDirs' => [],
+                               ] ),
+                               new LCStoreDB( [] ),
+                               new NullLogger
+                       ] )
                        ->setMethods( [ 'getMessagesDirs' ] )
                        ->getMock();
                $lc->expects( $this->any() )->method( 'getMessagesDirs' )
@@ -31,7 +45,7 @@ class LocalisationCacheTest extends MediaWikiTestCase {
                return $lc;
        }
 
-       public function testPuralRulesFallback() {
+       public function testPluralRulesFallback() {
                $cache = $this->getMockLocalisationCache();
 
                $this->assertEquals(
@@ -61,21 +75,21 @@ class LocalisationCacheTest extends MediaWikiTestCase {
 
        public function testRecacheFallbacks() {
                $lc = $this->getMockLocalisationCache();
-               $lc->recache( 'uk' );
+               $lc->recache( 'ba' );
                $this->assertEquals(
                        [
-                               'present-uk' => 'uk',
+                               'present-ba' => 'ba',
                                'present-ru' => 'ru',
                                'present-en' => 'en',
                        ],
-                       $lc->getItem( 'uk', 'messages' ),
+                       $lc->getItem( 'ba', 'messages' ),
                        'Fallbacks are only used to fill missing data'
                );
        }
 
        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 (
@@ -84,7 +98,7 @@ class LocalisationCacheTest extends MediaWikiTestCase {
                                        array &$cache
                                ) {
                                        if ( $code === 'ru' ) {
-                                               $cache['messages']['present-uk'] = 'ru-override';
+                                               $cache['messages']['present-ba'] = 'ru-override';
                                                $cache['messages']['present-ru'] = 'ru-override';
                                                $cache['messages']['present-en'] = 'ru-override';
                                        }
@@ -93,14 +107,14 @@ class LocalisationCacheTest extends MediaWikiTestCase {
                ] );
 
                $lc = $this->getMockLocalisationCache();
-               $lc->recache( 'uk' );
+               $lc->recache( 'ba' );
                $this->assertEquals(
                        [
-                               'present-uk' => 'uk',
+                               'present-ba' => 'ba',
                                'present-ru' => 'ru-override',
                                'present-en' => 'ru-override',
                        ],
-                       $lc->getItem( 'uk', 'messages' ),
+                       $lc->getItem( 'ba', 'messages' ),
                        'Updates provided by hooks follow the normal fallback order.'
                );
        }