]> git.mxchange.org Git - friendica.git/blob - tests/src/Core/Cache/MemcacheCacheTest.php
Add Drone CI
[friendica.git] / tests / src / Core / Cache / MemcacheCacheTest.php
1 <?php
2
3 namespace Friendica\Test\src\Core\Cache;
4
5 use Friendica\Core\Cache\MemcacheCache;
6 use Friendica\Core\Config\Configuration;
7
8 /**
9  * @requires extension memcache
10  */
11 class MemcacheCacheTest extends MemoryCacheTest
12 {
13         protected function getInstance()
14         {
15                 $configMock = \Mockery::mock(Configuration::class);
16
17                 $host = $_SERVER['MEMCACHE_HOST'] ?? 'localhost';
18
19                 $configMock
20                         ->shouldReceive('get')
21                         ->with('system', 'memcache_host')
22                         ->andReturn($host);
23                 $configMock
24                         ->shouldReceive('get')
25                         ->with('system', 'memcache_port')
26                         ->andReturn(11211);
27
28                 try {
29                         $this->cache = new MemcacheCache($host, $configMock);
30                 } catch (\Exception $e) {
31                         $this->markTestSkipped('Memcache is not available');
32                 }
33                 return $this->cache;
34         }
35
36         public function tearDown()
37         {
38                 $this->cache->clear(false);
39                 parent::tearDown();
40         }
41 }