namespace Friendica\Test\src\Core\Lock;
-
-use Friendica\Core\Cache\CacheDriverFactory;
use Friendica\Core\Lock\CacheLockDriver;
+use Friendica\Factory\CacheDriverFactory;
+/**
+ * @requires extension redis
+ */
class RedisCacheLockDriverTest extends LockTest
{
- /**
- * @var \Friendica\Core\Cache\IMemoryCacheDriver
- */
- private $cache;
-
protected function getInstance()
{
- if (class_exists('Redis')) {
- try {
- $this->cache = CacheDriverFactory::create('redis');
- } catch (\Exception $exception) {
- print "Redis - TestCase failed: " . $exception->getMessage();
- throw new \Exception();
- }
- return new CacheLockDriver($this->cache);
- } else {
- $this->markTestSkipped('Redis driver isn\'t available');
- return null;
- }
- }
+ $this->configMock
+ ->shouldReceive('get')
+ ->with('system', 'redis_host')
+ ->andReturn('localhost');
- public function tearDown()
- {
- if (class_exists('Redis')) {
- $this->cache->clear();
- }
- parent::tearDown();
+ $this->configMock
+ ->shouldReceive('get')
+ ->with('system', 'redis_port')
+ ->andReturn(null);
+
+ $this->configMock
+ ->shouldReceive('get')
+ ->with('system', 'redis_db')
+ ->andReturn(3);
+
+ $this->configMock
+ ->shouldReceive('get')
+ ->with('system', 'redis_password')
+ ->andReturn(null);
+
+ return new CacheLockDriver(CacheDriverFactory::create('redis'));
}
}