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