[HttpKernel] fix deprecation in AbstractTestSessionListener
This commit is contained in:
parent
7fb7cf26ad
commit
0ecaefe179
@ -61,10 +61,12 @@ abstract class AbstractTestSessionListener implements EventSubscriberInterface
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$session = $event->getRequest()->getSession()) {
|
$request = $event->getRequest();
|
||||||
|
if (!$request->hasSession()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$session = $request->getSession();
|
||||||
if ($wasStarted = $session->isStarted()) {
|
if ($wasStarted = $session->isStarted()) {
|
||||||
$session->save();
|
$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'));
|
$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)
|
private function filterResponse(Request $request, $type = HttpKernelInterface::MASTER_REQUEST)
|
||||||
{
|
{
|
||||||
$request->setSession($this->session);
|
$request->setSession($this->session);
|
||||||
|
Reference in New Issue
Block a user