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