Merge "objectcache: Complete coverage for newAnything()"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 11 Apr 2017 23:13:33 +0000 (23:13 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 11 Apr 2017 23:13:33 +0000 (23:13 +0000)
tests/phpunit/includes/objectcache/ObjectCacheTest.php

index d132183..f8ce24e 100644 (file)
@@ -63,7 +63,7 @@ class ObjectCacheTest extends MediaWikiTestCase {
        }
 
        /** @covers ObjectCache::newAnything */
-       public function txestNewAnythingNoAccel() {
+       public function testNewAnythingNoAccel() {
                $this->setMwGlobals( [
                        'wgMainCacheType' => CACHE_ACCEL
                ] );
@@ -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' ]
+               ] );
+
+               $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.'
+               );
+       }
 }