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