]> git.mxchange.org Git - friendica.git/blob - tests/src/Core/Cache/MemcachedCacheDriverTest.php
Move meaningful message inside Exception thrown in Cache tests
[friendica.git] / tests / src / Core / Cache / MemcachedCacheDriverTest.php
1 <?php
2
3
4 namespace Friendica\Test\src\Core\Cache;
5
6
7 use Friendica\Core\Cache\CacheDriverFactory;
8
9 class MemcachedCacheDriverTest extends MemoryCacheTest
10 {
11         /**
12          * @var \Friendica\Core\Cache\IMemoryCacheDriver
13          */
14         private $cache;
15
16         protected function getInstance()
17         {
18                 if (class_exists('Memcached')) {
19                         try {
20                                 $this->cache = CacheDriverFactory::create('memcached');
21                         } catch (\Exception $exception) {
22                                 throw new \Exception("Memcached - TestCase failed: " . $exception->getMessage(), $exception->getCode(), $exception);
23                         }
24                         return $this->cache;
25                 } else {
26                         $this->markTestSkipped('Memcached driver isn\'t available');
27                         return null;
28                 }
29         }
30
31         public function tearDown()
32         {
33                 if (class_exists('Memcached')) {
34                         $this->cache->clear(false);
35                 }
36                 parent::tearDown();
37         }
38 }