aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/objectcache/ObjectCacheTest.php
diff options
context:
space:
mode:
authorTimo Tijhof <krinklemail@gmail.com>2017-04-10 14:41:12 -0700
committerTimo Tijhof <krinklemail@gmail.com>2017-04-10 14:52:04 -0700
commitb586d83422ce27f90e73c3e6cd647a283f67cca8 (patch)
tree86ae6286798ea0648c8f7e5e2b9217a7fa7fffe7 /tests/phpunit/includes/objectcache/ObjectCacheTest.php
parent1fdd3ea38a717640eaf34c9462023bc82f906bf2 (diff)
downloadmediawikicore-b586d83422ce27f90e73c3e6cd647a283f67cca8.tar.gz
mediawikicore-b586d83422ce27f90e73c3e6cd647a283f67cca8.zip
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
Diffstat (limited to 'tests/phpunit/includes/objectcache/ObjectCacheTest.php')
-rw-r--r--tests/phpunit/includes/objectcache/ObjectCacheTest.php35
1 files changed, 34 insertions, 1 deletions
diff --git a/tests/phpunit/includes/objectcache/ObjectCacheTest.php b/tests/phpunit/includes/objectcache/ObjectCacheTest.php
index d132183eacd4..f8ce24ec5533 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.'
+ );
+ }
}