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