Merge "Fix jump-to-nav element overlap on RCFilters"
[lhc/web/wiklou.git] / tests / phpunit / includes / objectcache / ObjectCacheTest.php
index d132183..4318852 100644 (file)
@@ -16,13 +16,13 @@ class ObjectCacheTest extends MediaWikiTestCase {
 
        private function setCacheConfig( $arr = [] ) {
                $defaults = [
-                       CACHE_NONE => [ 'class' => 'EmptyBagOStuff' ],
-                       CACHE_DB => [ 'class' => 'SqlBagOStuff' ],
+                       CACHE_NONE => [ 'class' => EmptyBagOStuff::class ],
+                       CACHE_DB => [ 'class' => SqlBagOStuff::class ],
                        CACHE_ANYTHING => [ 'factory' => 'ObjectCache::newAnything' ],
                        // Mock ACCEL with 'hash' as being installed.
                        // This makes tests deterministic regardless of APC.
-                       CACHE_ACCEL => [ 'class' => 'HashBagOStuff' ],
-                       'hash' => [ 'class' => 'HashBagOStuff' ],
+                       CACHE_ACCEL => [ 'class' => HashBagOStuff::class ],
+                       'hash' => [ 'class' => HashBagOStuff::class ],
                ];
                $this->setMwGlobals( 'wgObjectCaches', $arr + $defaults );
        }
@@ -63,14 +63,14 @@ class ObjectCacheTest extends MediaWikiTestCase {
        }
 
        /** @covers ObjectCache::newAnything */
-       public function txestNewAnythingNoAccel() {
+       public function testNewAnythingNoAccel() {
                $this->setMwGlobals( [
                        'wgMainCacheType' => CACHE_ACCEL
                ] );
 
                $this->setCacheConfig( [
                        // Mock APC not being installed (T160519, T147161)
-                       CACHE_ACCEL => [ 'class' => 'EmptyBagOStuff' ]
+                       CACHE_ACCEL => [ 'class' => EmptyBagOStuff::class ]
                ] );
 
                $this->assertInstanceOf(
@@ -79,4 +79,37 @@ class ObjectCacheTest extends MediaWikiTestCase {
                        'Fallback to DB if available types fall back to Empty'
                );
        }
+
+       /** @covers ObjectCache::newAnything */
+       public function testNewAnythingNoAccelNoDb() {
+               $this->overrideMwServices(); // Ensures restore on tear down
+               MediaWiki\MediaWikiServices::disableStorageBackend();
+
+               $this->setMwGlobals( [
+                       'wgMainCacheType' => CACHE_ACCEL
+               ] );
+
+               $this->setCacheConfig( [
+                       // Mock APC not being installed (T160519, T147161)
+                       CACHE_ACCEL => [ 'class' => EmptyBagOStuff::class ]
+               ] );
+
+               $this->assertInstanceOf(
+                       EmptyBagOStuff::class,
+                       ObjectCache::newAnything( [] ),
+                       'Fallback to none if available types and DB are unavailable'
+               );
+       }
+
+       /** @covers ObjectCache::newAnything */
+       public function testNewAnythingNothingNoDb() {
+               $this->overrideMwServices();
+               MediaWiki\MediaWikiServices::disableStorageBackend();
+
+               $this->assertInstanceOf(
+                       EmptyBagOStuff::class,
+                       ObjectCache::newAnything( [] ),
+                       'No available types or DB. Fallback to none.'
+               );
+       }
 }