diff --git a/lib/private/memcache/factory.php b/lib/private/memcache/factory.php
index a3fc8dfe62cc93e200542dba5717be26e94e969d..fe82558e731e2e57343fece8d7e0e1ceca4baa00 100644
--- a/lib/private/memcache/factory.php
+++ b/lib/private/memcache/factory.php
@@ -82,7 +82,7 @@ class Factory implements ICacheFactory {
 		$missingCacheMessage = 'Memcache {class} not available for {use} cache';
 		$missingCacheHint = 'Is the matching PHP module installed and enabled?';
 		if (!$localCacheClass::isAvailable()) {
-			if (\OC::$CLI) {
+			if (\OC::$CLI && !defined('PHPUNIT_RUN')) {
 				// CLI should not hard-fail on broken memcache
 				$this->logger->info($missingCacheMessage, [
 					'class' => $localCacheClass,
@@ -97,7 +97,7 @@ class Factory implements ICacheFactory {
 			}
 		}
 		if (!$distributedCacheClass::isAvailable()) {
-			if (\OC::$CLI) {
+			if (\OC::$CLI && !defined('PHPUNIT_RUN')) {
 				// CLI should not hard-fail on broken memcache
 				$this->logger->info($missingCacheMessage, [
 					'class' => $distributedCacheClass,
diff --git a/tests/lib/memcache/factory.php b/tests/lib/memcache/factory.php
index c25e5937c16ece9e61361218ca0f6d82b4e6a433..33a27a421136dae567a60187f4de28c139548195 100644
--- a/tests/lib/memcache/factory.php
+++ b/tests/lib/memcache/factory.php
@@ -114,7 +114,8 @@ class Test_Factory extends \Test\TestCase {
 	 */
 	public function testCacheAvailability($localCache, $distributedCache, $lockingCache,
 		$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->createDistributed(), $expectedDistributedCache));
 		$this->assertTrue(is_a($factory->createLocking(), $expectedLockingCache));
@@ -125,6 +126,7 @@ class Test_Factory extends \Test\TestCase {
 	 * @expectedException \OC\HintException
 	 */
 	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);
 	}
 }