Files
yii/tests/framework/web/CCacheHttpSessionTest.php
Dirk Adler 9e532851b1 Fixes #4020: Fixed PHP 7 related bug in CCacheHttpSession when destroying not cached sessions
* CCacheHttpSession::destroySession now always returns true
* added CCacheHttpSessionTest
2016-03-06 01:06:55 +03:00

48 lines
1.0 KiB
PHP

<?php
class CCacheHttpSessionTest extends CTestCase
{
/**
* @covers CCacheHttpSession::writeSession
* @covers CCacheHttpSession::readSession
* @covers CCacheHttpSession::destroySession
*/
public function testCustomSessionHandler()
{
$config=array(
'components'=>array(
'cache'=>array(
'class'=>'CFileCache',
),
),
);
new TestApplication($config);
$session=new CCacheHttpSession();
$session->init();
$this->assertTrue($session->destroySession('test'));
$this->assertEquals('',$session->readSession('test'));
$this->assertTrue($session->writeSession('test','any value'));
$this->assertEquals('any value',$session->readSession('test'));
$this->assertTrue($session->destroySession('test'));
$this->assertEquals('',$session->readSession('test'));
}
/**
* @covers CCacheHttpSession::init
*/
public function testInvalidCache()
{
$session=new CCacheHttpSession();
$session->cacheID='invalidCacheID';
$this->setExpectedException('CException');
$session->init();
}
}