From: Timo Tijhof Date: Mon, 10 Apr 2017 21:41:12 +0000 (-0700) Subject: objectcache: Complete coverage for newAnything() X-Git-Tag: 1.31.0-rc.0~3536^2 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/cotisations/gestion/rappel_modifier.php?a=commitdiff_plain;h=b586d83422ce27f90e73c3e6cd647a283f67cca8;p=lhc%2Fweb%2Fwiklou.git objectcache: Complete coverage for newAnything() * Fix typo that disabled testNewAnythingNoAccel(). Follows-up c5a0fa5bed, accidentally committed a local hack to disable the test. * Add missing case other types falling back and no DB. * Add missing case of no other types and no DB. Change-Id: If158f21053f0b3741f2625fe4455fdb31955a22f --- diff --git a/tests/phpunit/includes/objectcache/ObjectCacheTest.php b/tests/phpunit/includes/objectcache/ObjectCacheTest.php index d132183eac..f8ce24ec55 100644 --- a/tests/phpunit/includes/objectcache/ObjectCacheTest.php +++ b/tests/phpunit/includes/objectcache/ObjectCacheTest.php @@ -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.' + ); + } }