[HttpKernel] fix deprecation in AbstractTestSessionListener
This commit is contained in:
parent
7fb7cf26ad
commit
0ecaefe179
@ -61,10 +61,12 @@ abstract class AbstractTestSessionListener implements EventSubscriberInterface
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$session = $event->getRequest()->getSession()) {
|
||||
$request = $event->getRequest();
|
||||
if (!$request->hasSession()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$session = $request->getSession();
|
||||
if ($wasStarted = $session->isStarted()) {
|
||||
$session->save();
|
||||
}
|
||||
|
@ -123,6 +123,16 @@ class TestSessionListenerTest extends TestCase
|
||||
$this->assertFalse(is_subclass_of(TestSessionListener::class, ServiceSubscriberInterface::class, 'Implementing ServiceSubscriberInterface would create a dep on the DI component, which eg Silex cannot afford'));
|
||||
}
|
||||
|
||||
public function testDoesNotThrowIfRequestDoesNotHaveASession()
|
||||
{
|
||||
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
|
||||
$event = new FilterResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, new Response());
|
||||
|
||||
$this->listener->onKernelResponse($event);
|
||||
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
private function filterResponse(Request $request, $type = HttpKernelInterface::MASTER_REQUEST)
|
||||
{
|
||||
$request->setSession($this->session);
|
||||
|
Reference in New Issue
Block a user