|
|
@ -1,5 +1,17 @@ |
|
|
|
<?php |
|
|
|
<?php |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace yii\caching; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Mock for the time() function for caching classes |
|
|
|
|
|
|
|
* @return int |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
function time() { |
|
|
|
|
|
|
|
return \yiiunit\framework\caching\CacheTest::$time ?: \time(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
namespace yiiunit\framework\caching; |
|
|
|
namespace yiiunit\framework\caching; |
|
|
|
|
|
|
|
|
|
|
|
use yiiunit\TestCase; |
|
|
|
use yiiunit\TestCase; |
|
|
|
use yii\caching\Cache; |
|
|
|
use yii\caching\Cache; |
|
|
|
|
|
|
|
|
|
|
@ -9,6 +21,12 @@ use yii\caching\Cache; |
|
|
|
abstract class CacheTest extends TestCase |
|
|
|
abstract class CacheTest extends TestCase |
|
|
|
{ |
|
|
|
{ |
|
|
|
/** |
|
|
|
/** |
|
|
|
|
|
|
|
* @var int virtual time to be returned by mocked time() function. |
|
|
|
|
|
|
|
* Null means normal time() behavior. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static $time; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* @return Cache |
|
|
|
* @return Cache |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
abstract protected function getCacheInstance(); |
|
|
|
abstract protected function getCacheInstance(); |
|
|
@ -19,6 +37,11 @@ abstract class CacheTest extends TestCase |
|
|
|
$this->mockApplication(); |
|
|
|
$this->mockApplication(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected function tearDown() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
static::$time = null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @return Cache |
|
|
|
* @return Cache |
|
|
|
*/ |
|
|
|
*/ |
|
|
|