Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0ecaefe

Browse filesBrowse files
committed
[HttpKernel] fix deprecation in AbstractTestSessionListener
1 parent 7fb7cf2 commit 0ecaefe
Copy full SHA for 0ecaefe

File tree

2 files changed

+13
-1
lines changed
Filter options

2 files changed

+13
-1
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/EventListener/AbstractTestSessionListener.php
+3-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php
+10Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.