]> git.mxchange.org Git - friendica.git/blob - tests/src/Core/Lock/RedisCacheLockTest.php
Add Drone CI
[friendica.git] / tests / src / Core / Lock / RedisCacheLockTest.php
1 <?php
2
3
4 namespace Friendica\Test\src\Core\Lock;
5
6 use Friendica\Core\Cache\RedisCache;
7 use Friendica\Core\Config\Configuration;
8 use Friendica\Core\Lock\CacheLock;
9
10 /**
11  * @requires extension redis
12  */
13 class RedisCacheLockTest extends LockTest
14 {
15         protected function getInstance()
16         {
17                 $configMock = \Mockery::mock(Configuration::class);
18
19                 $host = $_SERVER['REDIS_HOST'] ?? 'localhost';
20
21                 $configMock
22                         ->shouldReceive('get')
23                         ->with('system', 'redis_host')
24                         ->andReturn($host);
25                 $configMock
26                         ->shouldReceive('get')
27                         ->with('system', 'redis_port')
28                         ->andReturn(null);
29
30                 $configMock
31                         ->shouldReceive('get')
32                         ->with('system', 'redis_db', 0)
33                         ->andReturn(3);
34                 $configMock
35                         ->shouldReceive('get')
36                         ->with('system', 'redis_password')
37                         ->andReturn(null);
38
39                 $lock = null;
40
41                 try {
42                         $cache = new RedisCache($host, $configMock);
43                         $lock = new CacheLock($cache);
44                 } catch (\Exception $e) {
45                         $this->markTestSkipped('Redis is not available');
46                 }
47
48                 return $lock;
49         }
50 }