Security update for Core, with self-updated composer
[yaffs-website] / vendor / doctrine / cache / tests / Doctrine / Tests / Common / Cache / MemcacheCacheTest.php
1 <?php
2
3 namespace Doctrine\Tests\Common\Cache;
4
5 use Doctrine\Common\Cache\MemcacheCache;
6 use Memcache;
7
8 /**
9  * @requires extension memcache
10  */
11 class MemcacheCacheTest extends CacheTest
12 {
13     private $memcache;
14
15     protected function setUp()
16     {
17         $this->memcache = new Memcache();
18
19         if (@$this->memcache->connect('localhost', 11211) === false) {
20             unset($this->memcache);
21             $this->markTestSkipped('Cannot connect to Memcache.');
22         }
23     }
24
25     protected function tearDown()
26     {
27         if ($this->memcache instanceof Memcache) {
28             $this->memcache->flush();
29         }
30     }
31
32     /**
33      * {@inheritdoc}
34      *
35      * Memcache does not support " " and null byte as key so we remove them from the tests.
36      */
37     public function provideCacheIds()
38     {
39         $ids = parent::provideCacheIds();
40         unset($ids[21], $ids[22]);
41
42         return $ids;
43     }
44
45     public function testGetMemcacheReturnsInstanceOfMemcache()
46     {
47         $this->assertInstanceOf('Memcache', $this->_getCacheDriver()->getMemcache());
48     }
49
50     /**
51      * {@inheritDoc}
52      */
53     protected function _getCacheDriver()
54     {
55         $driver = new MemcacheCache();
56         $driver->setMemcache($this->memcache);
57         return $driver;
58     }
59 }