Security update for Core, with self-updated composer
[yaffs-website] / vendor / doctrine / cache / tests / Doctrine / Tests / Common / Cache / MemcachedCacheTest.php
diff --git a/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/MemcachedCacheTest.php b/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/MemcachedCacheTest.php
new file mode 100644 (file)
index 0000000..fbcf5c3
--- /dev/null
@@ -0,0 +1,61 @@
+<?php
+
+namespace Doctrine\Tests\Common\Cache;
+
+use Doctrine\Common\Cache\MemcachedCache;
+use Memcached;
+
+/**
+ * @requires extension memcached
+ */
+class MemcachedCacheTest extends CacheTest
+{
+    private $memcached;
+
+    protected function setUp()
+    {
+        $this->memcached = new Memcached();
+        $this->memcached->setOption(Memcached::OPT_COMPRESSION, false);
+        $this->memcached->addServer('127.0.0.1', 11211);
+
+        if (@fsockopen('127.0.0.1', 11211) === false) {
+            unset($this->memcached);
+            $this->markTestSkipped('Cannot connect to Memcached.');
+        }
+    }
+
+    protected function tearDown()
+    {
+        if ($this->memcached instanceof Memcached) {
+            $this->memcached->flush();
+        }
+    }
+
+    /**
+     * {@inheritdoc}
+     *
+     * Memcached does not support " ", null byte and very long keys so we remove them from the tests.
+     */
+    public function provideCacheIds()
+    {
+        $ids = parent::provideCacheIds();
+        unset($ids[21], $ids[22], $ids[24]);
+
+        return $ids;
+    }
+
+    public function testGetMemcachedReturnsInstanceOfMemcached()
+    {
+        $this->assertInstanceOf('Memcached', $this->_getCacheDriver()->getMemcached());
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    protected function _getCacheDriver()
+    {
+        $driver = new MemcachedCache();
+        $driver->setMemcached($this->memcached);
+        return $driver;
+    }
+}