From 4fd947697cea1afa7222dd12d05d5b6dc726a987 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 30 Nov 2017 11:09:16 +0100 Subject: [PATCH] [HttpKernel] empty-session should mean no-cookie to AbstractTestSessionListener --- .../HttpKernel/EventListener/AbstractTestSessionListener.php | 2 +- .../Tests/EventListener/TestSessionListenerTest.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpKernel/EventListener/AbstractTestSessionListener.php b/src/Symfony/Component/HttpKernel/EventListener/AbstractTestSessionListener.php index eb0320f6b91e6..81f6c26d80348 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/AbstractTestSessionListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/AbstractTestSessionListener.php @@ -58,7 +58,7 @@ public function onKernelResponse(FilterResponseEvent $event) } $session = $event->getRequest()->getSession(); - if ($session && $session->isStarted()) { + if ($session && $session->isStarted() && $session->all()) { $session->save(); $params = session_get_cookie_params(); $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'])); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php index 124bd64d848f3..5930234eff47c 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php @@ -121,6 +121,10 @@ private function sessionHasBeenStarted() $this->session->expects($this->once()) ->method('isStarted') ->will($this->returnValue(true)); + + $this->session->expects($this->once()) + ->method('all') + ->will($this->returnValue(array('foo' => 'bar'))); } private function sessionHasNotBeenStarted()