]> git.mxchange.org Git - friendica.git/blob - tests/src/Core/Cache/MemcacheCacheTest.php
Add group for cache tests
[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  * @group MEMCACHE
11  */
12 class MemcacheCacheTest extends MemoryCacheTest
13 {
14         protected function getInstance()
15         {
16                 $configMock = \Mockery::mock(Configuration::class);
17
18                 $host = $_SERVER['MEMCACHE_HOST'] ?? 'localhost';
19
20                 $configMock
21                         ->shouldReceive('get')
22                         ->with('system', 'memcache_host')
23                         ->andReturn($host);
24                 $configMock
25                         ->shouldReceive('get')
26                         ->with('system', 'memcache_port')
27                         ->andReturn(11211);
28
29                 try {
30                         $this->cache = new MemcacheCache($host, $configMock);
31                 } catch (\Exception $e) {
32                         $this->markTestSkipped('Memcache is not available');
33                 }
34                 return $this->cache;
35         }
36
37         public function tearDown()
38         {
39                 $this->cache->clear(false);
40                 parent::tearDown();
41         }
42 }