Added Lock Unittests & Bugfixings
[friendica.git/.git] / tests / src / Core / Lock / MemcachedCacheLockDriverTest.php
1 <?php
2
3
4 namespace Friendica\Test\src\Core\Lock;
5
6
7 use Friendica\Core\Cache\CacheDriverFactory;
8 use Friendica\Core\Lock\CacheLockDriver;
9
10 class MemcachedCacheLockDriverTest extends LockTest
11 {
12         /**
13          * @var \Friendica\Core\Cache\IMemoryCacheDriver
14          */
15         private $cache;
16
17         protected function getInstance()
18         {
19                 if (class_exists('Memcached')) {
20                         try {
21                                 $this->cache = CacheDriverFactory::create('memcached');
22                         } catch (\Exception $exception) {
23                                 print "Redis - TestCase failed: " . $exception->getMessage();
24                                 throw new \Exception();
25                         }
26                         return new CacheLockDriver($this->cache);
27                 } else {
28                         $this->markTestSkipped('Redis driver isn\'t available');
29                         return null;
30                 }
31         }
32
33         public function tearDown()
34         {
35                 if (class_exists('Redis')) {
36                         $this->cache->clear();
37                 }
38                 parent::tearDown();
39         }
40 }