fixed an issue with session mocking in functional tests that do not start with a fresh session instance for each request (Silex for instance)
This commit is contained in:
parent
171eecf679
commit
66ff06096c
@ -42,7 +42,7 @@ class SessionController extends ContainerAware
|
||||
|
||||
public function logoutAction()
|
||||
{
|
||||
$request = $this->container->get('request')->getSession('session')->clear();
|
||||
$request = $this->container->get('request')->getSession('session')->invalidate();
|
||||
|
||||
return new Response('Session cleared.');
|
||||
}
|
||||
|
@ -93,6 +93,11 @@ class MockFileSessionStorage extends MockArraySessionStorage
|
||||
public function save()
|
||||
{
|
||||
$this->handler->write($this->id, serialize($this->data));
|
||||
|
||||
// this is needed for Silex, where the session object is re-used across requests
|
||||
// in functional tests. In Symfony, the container is rebooted, so we don't have
|
||||
// this issue
|
||||
$this->started = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -111,8 +111,8 @@ class MockFileSessionStorageTest extends \PHPUnit_Framework_TestCase
|
||||
private function getStorage()
|
||||
{
|
||||
$storage = new MockFileSessionStorage($this->sessionDir);
|
||||
$storage->registerBag(new FlashBag);
|
||||
$storage->registerBag(new AttributeBag);
|
||||
$storage->registerBag(new FlashBag());
|
||||
$storage->registerBag(new AttributeBag());
|
||||
|
||||
return $storage;
|
||||
}
|
||||
|
Reference in New Issue
Block a user