]> git.mxchange.org Git - friendica.git/blob - tests/src/Core/Cache/RedisCacheTest.php
Merge pull request #8079 from ozero/patch-1
[friendica.git] / tests / src / Core / Cache / RedisCacheTest.php
1 <?php
2
3
4 namespace Friendica\Test\src\Core\Cache;
5
6 use Friendica\Core\Cache\RedisCache;
7 use Friendica\Core\Config\IConfiguration;
8
9 /**
10  * @requires extension redis
11  * @group REDIS
12  */
13 class RedisCacheTest extends MemoryCacheTest
14 {
15         protected function getInstance()
16         {
17                 $configMock = \Mockery::mock(IConfiguration::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                 try {
40                         $this->cache = new RedisCache($host, $configMock);
41                 } catch (\Exception $e) {
42                         $this->markTestSkipped('Redis is not available.');
43                 }
44                 return $this->cache;
45         }
46
47         public function tearDown()
48         {
49                 $this->cache->clear(false);
50                 parent::tearDown();
51         }
52 }