8000 [FrameworkBundle] Fixed logic under test environment. · symfony/symfony@54d3f81 · GitHub
[go: up one dir, main page]

Skip to content

Commit 54d3f81

Browse files
author
Drak
committed
[FrameworkBundle] Fixed logic under test environment.
1 parent c67ddb2 commit 54d3f81

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/Symfony/Bundle/FrameworkBundle/EventListener/TestSessionListener.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,10 @@ public function onKernelResponse(FilterResponseEvent $event)
6767
return;
6868
}
6969

70-
if ($session = $event->getRequest()->getSession()) {
71-
if ($session->isStarted()) {
72-
$session->save();
73-
}
74-
70+
$session = $event->getRequest()->getSession();
71+
if ($session && $session->isStarted()) {
72+
$session->save();
7573
$params = session_get_cookie_params();
76-
7774
$event->getResponse()->headers->setCookie(new Cookie($session->getName(), $session->getId(), 0 === $params['lifetime'] ? 0 : time() + $params['lifetime'], $params['path'], $params['domain'], $params['secure'], $params['httponly']));
7875
}
7976
}

src/Symfony/Bundle/FrameworkBundle/Tests/EventListener/TestSessionListenerTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\HttpFoundation\Request;
1717
use Symfony\Component\HttpKernel\HttpKernelInterface;
1818
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
19+
use Symfony\Component\HttpFoundation\Session\SessionInterface;
1920

2021
/**
2122
* SessionListenerTest.
@@ -26,7 +27,14 @@
2627
*/
2728
class TestSessionListenerTest extends \PHPUnit_Framework_TestCase
2829
{
30+
/**
31+
* @var TestSessionListener
32+
*/
2933
private $listener;
34+
35+
/**
36+
* @var SessionInterface
37+
*/
3038
private $session;
3139

3240
protected function setUp()
@@ -58,6 +66,8 @@ public function testShouldNotSaveSubRequestSession()
5866

5967
public function testDoesNotDeleteCookieIfUsingSessionLifetime()
6068
{
69+
$this->sessionHasBeenStarted();
70+
6171
$params = session_get_cookie_params();
6272
session_set_cookie_params(0, $params['path'], $params['domain'], $params['secure'], $params['httponly']);
6373

0 commit comments

Comments
 (0)
0