summaryrefslogtreecommitdiff
path: root/vendor/guzzle/guzzle/tests/Guzzle/Tests/Cache/Zf2CacheAdapterTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/guzzle/guzzle/tests/Guzzle/Tests/Cache/Zf2CacheAdapterTest.php')
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Cache/Zf2CacheAdapterTest.php58
1 files changed, 58 insertions, 0 deletions
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Cache/Zf2CacheAdapterTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Cache/Zf2CacheAdapterTest.php
new file mode 100644
index 0000000..9077c12
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Cache/Zf2CacheAdapterTest.php
@@ -0,0 +1,58 @@
+<?php
+
+namespace Guzzle\Tests\Cache;
+
+use Guzzle\Cache\Zf2CacheAdapter;
+use Zend\Cache\StorageFactory;
+
+/**
+ * @covers Guzzle\Cache\Zf2CacheAdapter
+ */
+class Zf2CacheAdapterTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ private $cache;
+ private $adapter;
+
+ /**
+ * Prepares the environment before running a test.
+ */
+ protected function setUp()
+ {
+ parent::setUp();
+ $this->cache = StorageFactory::factory(array(
+ 'adapter' => 'memory'
+ ));
+ $this->adapter = new Zf2CacheAdapter($this->cache);
+ }
+
+ /**
+ * Cleans up the environment after running a test.
+ */
+ protected function tearDown()
+ {
+ $this->adapter = null;
+ $this->cache = null;
+ parent::tearDown();
+ }
+
+ public function testCachesDataUsingCallables()
+ {
+ $this->assertTrue($this->adapter->save('test', 'data', 1000));
+ $this->assertEquals('data', $this->adapter->fetch('test'));
+ }
+
+ public function testChecksIfCacheContainsKeys()
+ {
+ $this->adapter->save('test', 'data', 1000);
+ $this->assertTrue($this->adapter->contains('test'));
+ $this->assertFalse($this->adapter->contains('foo'));
+ }
+
+ public function testDeletesFromCacheByKey()
+ {
+ $this->adapter->save('test', 'data', 1000);
+ $this->assertTrue($this->adapter->contains('test'));
+ $this->adapter->delete('test');
+ $this->assertFalse($this->adapter->contains('test'));
+ }
+}