8000 fixed an issue with session mocking in functional tests that do not s… · symfony/symfony@66ff060 · GitHub
[go: up one dir, main page]

Skip to content

Commit 66ff060

Browse files
committed
fixed an issue with session mocking in functional tests that do not start with a fresh session instance for each request (Silex for instance)
1 parent 171eecf commit 66ff060

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/SessionController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function welcomeAction($name=null)
4242

4343
public function logoutAction()
4444
{
45-
$request = $this->container->get('request')->getSession('session')->clear();
45+
$request = $this->container->get('request')->getSession('session')->invalidate();
4646

4747
return new Response('Session cleared.');
4848
}

src/Symfony/Component/HttpFoundation/Session/Storage/MockFileSessionStorage.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ public function regenerate($destroy = false, $lifetime = null)
9393
public function save()
9494
{
9595
$this->handler->write($this->id, serialize($this->data));
96+
97+
// this is needed for Silex, where the session object is re-used across requests
98+
// in functional tests. In Symfony, the container is rebooted, so we don't have
99+
// this issue
100+
$this->started = false;
96101
}
97102

98103
/**

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockFileSessionStorageTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ public function testMultipleInstances()
111111
private function getStorage()
112112
{
113113
$storage = new MockFileSessionStorage($this->sessionDir);
114-
$storage->registerBag(new FlashBag);
115-
$storage->registerBag(new AttributeBag);
114+
$storage->registerBag(new FlashBag());
115+
$storage->registerBag(new AttributeBag());
116116

117117
return $storage;
118118
}

0 commit comments

Comments
 (0)
0