diff --git a/tests/unit/framework/caching/CacheTest.php b/tests/unit/framework/caching/CacheTest.php index c524956..4b34de0 100644 --- a/tests/unit/framework/caching/CacheTest.php +++ b/tests/unit/framework/caching/CacheTest.php @@ -1,5 +1,17 @@ mockApplication(); } + protected function tearDown() + { + static::$time = null; + } + /** * @return Cache */ diff --git a/tests/unit/framework/caching/DbCacheTest.php b/tests/unit/framework/caching/DbCacheTest.php index 36174b9..a2ff9e3 100644 --- a/tests/unit/framework/caching/DbCacheTest.php +++ b/tests/unit/framework/caching/DbCacheTest.php @@ -1,5 +1,7 @@ _cacheInstance; } + + public function testExpire() + { + $cache = $this->getCacheInstance(); + + $this->assertTrue($cache->set('expire_test', 'expire_test', 2)); + static::$time = time() + 1; + $this->assertEquals('expire_test', $cache->get('expire_test')); + static::$time = time() + 2; + $this->assertFalse($cache->get('expire_test')); + } } diff --git a/tests/unit/framework/caching/FileCacheTest.php b/tests/unit/framework/caching/FileCacheTest.php index 99e3cbc..4499d9c 100644 --- a/tests/unit/framework/caching/FileCacheTest.php +++ b/tests/unit/framework/caching/FileCacheTest.php @@ -22,4 +22,15 @@ class FileCacheTest extends CacheTest } return $this->_cacheInstance; } + + public function testExpire() + { + $cache = $this->getCacheInstance(); + + $this->assertTrue($cache->set('expire_test', 'expire_test', 2)); + static::$time = time() + 1; + $this->assertEquals('expire_test', $cache->get('expire_test')); + static::$time = time() + 2; + $this->assertFalse($cache->get('expire_test')); + } }