8000 [HttpKernel] fix deprecation in AbstractTestSessionListener · symfony/symfony@0ecaefe · GitHub
[go: up one dir, main page]

Skip to content

Commit 0ecaefe

Browse files
committed
[HttpKernel] fix deprecation in AbstractTestSessionListener
1 parent 7fb7cf2 commit 0ecaefe

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Symfony/Component/HttpKernel/EventListener/AbstractTestSessionListener.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,12 @@ public function onKernelResponse(FilterResponseEvent $event)
6161
return;
6262
}
6363

64-
if (!$session = $event->getRequest()->getSession()) {
64+
$request = $event->getRequest();
65+
if (!$request->hasSession()) {
6566
return;
6667
}
6768

69+
$session = $request->getSession();
6870
if ($wasStarted = $session->isStarted()) {
6971
$session->save();
7072
}

src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,16 @@ public function testDoesNotImplementServiceSubscriberInterface()
123123
$this->assertFalse(is_subclass_of(TestSessionListener::class, ServiceSubscriberInterface::class, 'Implementing ServiceSubscriberInterface would create a dep on the DI component, which eg Silex cannot afford'));
124124
}
125125

126+
public function testDoesNotThrowIfRequestDoesNotHaveASession()
127+
{
128+
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
129+
$event = new FilterResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, new Response());
130+
131+
$this->listener->onKernelResponse($event);
132+
133+
$this->assertTrue(true);
134+
}
135+
126136
private function filterResponse(Request $request, $type = HttpKernelInterface::MASTER_REQUEST)
127137
{
128138
$request->setSession($this->session);

0 commit comments

Comments
 (0)
0