Skip to content
Snippets Groups Projects
Commit 8efa23c8 authored by Robin McCorkell's avatar Robin McCorkell
Browse files

Fix memcache factory unit tests

parent e556d97b
No related branches found
No related tags found
No related merge requests found
...@@ -82,7 +82,7 @@ class Factory implements ICacheFactory { ...@@ -82,7 +82,7 @@ class Factory implements ICacheFactory {
$missingCacheMessage = 'Memcache {class} not available for {use} cache'; $missingCacheMessage = 'Memcache {class} not available for {use} cache';
$missingCacheHint = 'Is the matching PHP module installed and enabled?'; $missingCacheHint = 'Is the matching PHP module installed and enabled?';
if (!$localCacheClass::isAvailable()) { if (!$localCacheClass::isAvailable()) {
if (\OC::$CLI) { if (\OC::$CLI && !defined('PHPUNIT_RUN')) {
// CLI should not hard-fail on broken memcache // CLI should not hard-fail on broken memcache
$this->logger->info($missingCacheMessage, [ $this->logger->info($missingCacheMessage, [
'class' => $localCacheClass, 'class' => $localCacheClass,
...@@ -97,7 +97,7 @@ class Factory implements ICacheFactory { ...@@ -97,7 +97,7 @@ class Factory implements ICacheFactory {
} }
} }
if (!$distributedCacheClass::isAvailable()) { if (!$distributedCacheClass::isAvailable()) {
if (\OC::$CLI) { if (\OC::$CLI && !defined('PHPUNIT_RUN')) {
// CLI should not hard-fail on broken memcache // CLI should not hard-fail on broken memcache
$this->logger->info($missingCacheMessage, [ $this->logger->info($missingCacheMessage, [
'class' => $distributedCacheClass, 'class' => $distributedCacheClass,
......
...@@ -114,7 +114,8 @@ class Test_Factory extends \Test\TestCase { ...@@ -114,7 +114,8 @@ class Test_Factory extends \Test\TestCase {
*/ */
public function testCacheAvailability($localCache, $distributedCache, $lockingCache, public function testCacheAvailability($localCache, $distributedCache, $lockingCache,
$expectedLocalCache, $expectedDistributedCache, $expectedLockingCache) { $expectedLocalCache, $expectedDistributedCache, $expectedLockingCache) {
$factory = new \OC\Memcache\Factory('abc', $localCache, $distributedCache, $lockingCache); $logger = $this->getMockBuilder('\OCP\ILogger')->getMock();
$factory = new \OC\Memcache\Factory('abc', $logger, $localCache, $distributedCache, $lockingCache);
$this->assertTrue(is_a($factory->createLocal(), $expectedLocalCache)); $this->assertTrue(is_a($factory->createLocal(), $expectedLocalCache));
$this->assertTrue(is_a($factory->createDistributed(), $expectedDistributedCache)); $this->assertTrue(is_a($factory->createDistributed(), $expectedDistributedCache));
$this->assertTrue(is_a($factory->createLocking(), $expectedLockingCache)); $this->assertTrue(is_a($factory->createLocking(), $expectedLockingCache));
...@@ -125,6 +126,7 @@ class Test_Factory extends \Test\TestCase { ...@@ -125,6 +126,7 @@ class Test_Factory extends \Test\TestCase {
* @expectedException \OC\HintException * @expectedException \OC\HintException
*/ */
public function testCacheNotAvailableException($localCache, $distributedCache) { public function testCacheNotAvailableException($localCache, $distributedCache) {
new \OC\Memcache\Factory('abc', $localCache, $distributedCache); $logger = $this->getMockBuilder('\OCP\ILogger')->getMock();
new \OC\Memcache\Factory('abc', $logger, $localCache, $distributedCache);
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment