Skip to content
Snippets Groups Projects
Commit bfda0fef authored by efalcy's avatar efalcy
Browse files

CVS : clear cache when logout

parent 4f4062c5
No related merge requests found
......@@ -21,11 +21,21 @@
class ZendAfi_Auth_Storage_Session extends Zend_Auth_Storage_Session {
public function write($contents) {
xdebug_break();
parent::write($contents);
Zend_Registry::get('cache')->save(serialize($contents),md5(Zend_Session::getId()));
Zend_Registry::get('cache')->save(serialize($contents),$this->getCacheKey());
}
public function getCacheKey() {
return md5(Zend_Session::getId());
}
public function clear()
{
parent::clear();
Zend_Registry::get('cache')->remove($this->getCacheKey());
}
}
?>
\ No newline at end of file
......@@ -25,13 +25,15 @@ class AuthSessionNamespaceTest extends PHPUnit_Framework_TestCase {
$this->old_cache=Zend_Registry::get('cache');
$this->cache_mock=Storm_Test_ObjectWrapper::mock();
$this->cache_mock->whenCalled('save')
->answers(true)
->whenCalled('remove')
->answers(true);
Zend_Registry::set('cache',$this->cache_mock);
$zendAuth = ZendAfi_Auth::getInstance();
$this->islogged=$zendAuth->authenticateLoginPassword('sysadm','adminPassword',[new Mock_ZendAfi_Auth_MD5_Adapter()]);
$this->zendAuth = ZendAfi_Auth::getInstance();
$this->islogged=$this->zendAuth->authenticateLoginPassword('sysadm','adminPassword',[new Mock_ZendAfi_Auth_MD5_Adapter()]);
}
......@@ -56,10 +58,17 @@ class AuthSessionNamespaceTest extends PHPUnit_Framework_TestCase {
$this->assertTrue($this->islogged);
}
/** @test */
/** @test */
public function validAuthenticationShouldBeStoredInCache() {
$this->assertEquals('sysadm',unserialize($this->cache_mock->getFirstAttributeForLastCallOn('save'))->LOGIN);
}
/** @test */
public function logoutShouldClearCache() {
$this->zendAuth->clearIdentity();
$this->assertTrue($this->cache_mock->methodHasBeenCalled('remove'));
}
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment