From 48f388442f0ed19e1d35db35d539221486d5db97 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Sat, 11 May 2013 16:08:14 +0200 Subject: [PATCH] mocking time in test only usefull when using time() once https://github.com/yiisoft/yii2/commit/e2513de6c6207fa37894a944e10b8cd420ac6804#commitcomment-3192244 --- tests/unit/framework/caching/DbCacheTest.php | 5 +++-- tests/unit/framework/caching/FileCacheTest.php | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/unit/framework/caching/DbCacheTest.php b/tests/unit/framework/caching/DbCacheTest.php index a2ff9e3..f5bbba5 100644 --- a/tests/unit/framework/caching/DbCacheTest.php +++ b/tests/unit/framework/caching/DbCacheTest.php @@ -77,10 +77,11 @@ class DbCacheTest extends CacheTest { $cache = $this->getCacheInstance(); + static::$time = \time(); $this->assertTrue($cache->set('expire_test', 'expire_test', 2)); - static::$time = time() + 1; + static::$time++; $this->assertEquals('expire_test', $cache->get('expire_test')); - static::$time = time() + 2; + static::$time++; $this->assertFalse($cache->get('expire_test')); } } diff --git a/tests/unit/framework/caching/FileCacheTest.php b/tests/unit/framework/caching/FileCacheTest.php index 4499d9c..b3ac8b7 100644 --- a/tests/unit/framework/caching/FileCacheTest.php +++ b/tests/unit/framework/caching/FileCacheTest.php @@ -27,10 +27,11 @@ class FileCacheTest extends CacheTest { $cache = $this->getCacheInstance(); + static::$time = \time(); $this->assertTrue($cache->set('expire_test', 'expire_test', 2)); - static::$time = time() + 1; + static::$time++; $this->assertEquals('expire_test', $cache->get('expire_test')); - static::$time = time() + 2; + static::$time++; $this->assertFalse($cache->get('expire_test')); } }