| 1 | <?php |
||
| 12 | class MemcacheCacheTest extends CacheTest |
||
| 13 | { |
||
| 14 | private $memcache; |
||
| 15 | |||
| 16 | protected function setUp() : void |
||
| 17 | { |
||
| 18 | $this->memcache = new Memcache(); |
||
| 19 | |||
| 20 | if (@$this->memcache->connect('localhost', 11211) !== false) { |
||
| 21 | return; |
||
| 22 | } |
||
| 23 | |||
| 24 | unset($this->memcache); |
||
| 25 | $this->markTestSkipped('Cannot connect to Memcache.'); |
||
| 26 | } |
||
| 27 | |||
| 28 | protected function tearDown() : void |
||
| 29 | { |
||
| 30 | if (! ($this->memcache instanceof Memcache)) { |
||
| 31 | return; |
||
| 32 | } |
||
| 33 | |||
| 34 | $this->memcache->flush(); |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * {@inheritdoc} |
||
| 39 | * |
||
| 40 | * Memcache does not support " " and null byte as key so we remove them from the tests. |
||
| 41 | */ |
||
| 42 | public function provideCacheIds() : array |
||
| 43 | { |
||
| 44 | $ids = parent::provideCacheIds(); |
||
| 45 | unset($ids[21], $ids[22]); |
||
| 46 | |||
| 47 | return $ids; |
||
| 48 | } |
||
| 49 | |||
| 50 | public function testGetMemcacheReturnsInstanceOfMemcache() : void |
||
| 51 | { |
||
| 52 | self::assertInstanceOf('Memcache', $this->_getCacheDriver()->getMemcache()); |
||
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * {@inheritDoc} |
||
| 57 | */ |
||
| 58 | protected function _getCacheDriver() : CacheProvider |
||
| 59 | { |
||
| 60 | $driver = new MemcacheCache(); |
||
| 61 | $driver->setMemcache($this->memcache); |
||
| 65 |