summaryrefslogtreecommitdiffstats
path: root/tests/lib/memcache
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-06-09 15:22:33 +0200
committerVincent Petry <pvince81@owncloud.com>2015-06-12 12:33:06 +0200
commit3b08b2658954b95932af8eec7cfaac17b1da7873 (patch)
tree6df71b8ae97559b0781c4f5cc9bc267764a97393 /tests/lib/memcache
parentdbe344ef3dc3ea643513fce8d76d1979d733c49a (diff)
downloadnextcloud-server-3b08b2658954b95932af8eec7cfaac17b1da7873.tar.gz
nextcloud-server-3b08b2658954b95932af8eec7cfaac17b1da7873.zip
Throw exception if memcache misconfigured or missing
Instead of falling back to null memcache, throw exceptions. Also throw file locking specific exceptions in case the class is not available.
Diffstat (limited to 'tests/lib/memcache')
-rw-r--r--tests/lib/memcache/factory.php64
1 files changed, 42 insertions, 22 deletions
diff --git a/tests/lib/memcache/factory.php b/tests/lib/memcache/factory.php
index 4ce032abbe8..c25e5937c16 100644
--- a/tests/lib/memcache/factory.php
+++ b/tests/lib/memcache/factory.php
@@ -66,45 +66,65 @@ class Test_Factory extends \Test\TestCase {
return [
[
// local and distributed available
- self::AVAILABLE1, self::AVAILABLE2,
- self::AVAILABLE1, self::AVAILABLE2
+ self::AVAILABLE1, self::AVAILABLE2, null,
+ self::AVAILABLE1, self::AVAILABLE2, \OC\Memcache\Factory::NULL_CACHE
],
[
- // local available, distributed unavailable
- self::AVAILABLE1, self::UNAVAILABLE1,
- self::AVAILABLE1, self::AVAILABLE1
+ // local and distributed null
+ null, null, null,
+ \OC\Memcache\Factory::NULL_CACHE, \OC\Memcache\Factory::NULL_CACHE, \OC\Memcache\Factory::NULL_CACHE
],
[
- // local unavailable, distributed available
- self::UNAVAILABLE1, self::AVAILABLE1,
- \OC\Memcache\Factory::NULL_CACHE, self::AVAILABLE1
+ // local available, distributed null (most common scenario)
+ self::AVAILABLE1, null, null,
+ self::AVAILABLE1, self::AVAILABLE1, \OC\Memcache\Factory::NULL_CACHE
],
[
- // local and distributed unavailable
- self::UNAVAILABLE1, self::UNAVAILABLE2,
- \OC\Memcache\Factory::NULL_CACHE, \OC\Memcache\Factory::NULL_CACHE
+ // locking cache available
+ null, null, self::AVAILABLE1,
+ \OC\Memcache\Factory::NULL_CACHE, \OC\Memcache\Factory::NULL_CACHE, self::AVAILABLE1
],
[
- // local and distributed null
- null, null,
- \OC\Memcache\Factory::NULL_CACHE, \OC\Memcache\Factory::NULL_CACHE
+ // locking cache unavailable: no exception here in the factory
+ null, null, self::UNAVAILABLE1,
+ \OC\Memcache\Factory::NULL_CACHE, \OC\Memcache\Factory::NULL_CACHE, \OC\Memcache\Factory::NULL_CACHE
+ ]
+ ];
+ }
+
+ public function cacheUnavailableProvider() {
+ return [
+ [
+ // local available, distributed unavailable
+ self::AVAILABLE1, self::UNAVAILABLE1
],
[
- // local available, distributed null (most common scenario)
- self::AVAILABLE1, null,
- self::AVAILABLE1, self::AVAILABLE1
- ]
+ // local unavailable, distributed available
+ self::UNAVAILABLE1, self::AVAILABLE1
+ ],
+ [
+ // local and distributed unavailable
+ self::UNAVAILABLE1, self::UNAVAILABLE2
+ ],
];
}
/**
* @dataProvider cacheAvailabilityProvider
*/
- public function testCacheAvailability($localCache, $distributedCache,
- $expectedLocalCache, $expectedDistributedCache)
- {
- $factory = new \OC\Memcache\Factory('abc', $localCache, $distributedCache);
+ public function testCacheAvailability($localCache, $distributedCache, $lockingCache,
+ $expectedLocalCache, $expectedDistributedCache, $expectedLockingCache) {
+ $factory = new \OC\Memcache\Factory('abc', $localCache, $distributedCache, $lockingCache);
$this->assertTrue(is_a($factory->createLocal(), $expectedLocalCache));
$this->assertTrue(is_a($factory->createDistributed(), $expectedDistributedCache));
+ $this->assertTrue(is_a($factory->createLocking(), $expectedLockingCache));
+ }
+
+ /**
+ * @dataProvider cacheUnavailableProvider
+ * @expectedException \OC\HintException
+ */
+ public function testCacheNotAvailableException($localCache, $distributedCache) {
+ new \OC\Memcache\Factory('abc', $localCache, $distributedCache);
}
}