mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-19 01:34:44 +08:00
100% test coverage for CacheSession
This commit is contained in:
@ -18,11 +18,22 @@ class CacheSessionTest extends \yiiunit\TestCase
|
|||||||
Yii::$app->setComponent('cache', new FileCache());
|
Yii::$app->setComponent('cache', new FileCache());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreate()
|
public function testCacheSession()
|
||||||
{
|
{
|
||||||
$session = new CacheSession();
|
$session = new CacheSession();
|
||||||
|
|
||||||
$session->writeSession('test', 'sessionData');
|
$session->writeSession('test', 'sessionData');
|
||||||
$this->assertEquals('sessionData', $session->readSession('test'));
|
$this->assertEquals('sessionData', $session->readSession('test'));
|
||||||
|
$session->destroySession('test');
|
||||||
|
$this->assertEquals('', $session->readSession('test'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testInvalidCache()
|
||||||
|
{
|
||||||
|
$this->setExpectedException('yii\base\InvalidConfigException');
|
||||||
|
|
||||||
|
$session = new CacheSession(array(
|
||||||
|
'cache' => 'invalid',
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user