merged branch drak/frameworktestsession (PR #6369)
This PR was merged into the 2.1 branch.
Commits
-------
54d3f81
[FrameworkBundle] Fixed logic under test environment.
Discussion
----------
[FrameworkBundle] Fixed logic under test environment.
Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets:-
Todo: -
License of the code: MIT
Documentation PR: -
Please note the travis build failed on some Forms stuff which is nothing to do with this PR.
This commit is contained in:
commit
021de7270a
@ -67,13 +67,10 @@ class TestSessionListener implements EventSubscriberInterface
|
||||
return;
|
||||
}
|
||||
|
||||
if ($session = $event->getRequest()->getSession()) {
|
||||
if ($session->isStarted()) {
|
||||
$session->save();
|
||||
}
|
||||
|
||||
$session = $event->getRequest()->getSession();
|
||||
if ($session && $session->isStarted()) {
|
||||
$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']));
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
||||
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
||||
|
||||
/**
|
||||
* SessionListenerTest.
|
||||
@ -26,7 +27,14 @@ use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
||||
*/
|
||||
class TestSessionListenerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var TestSessionListener
|
||||
*/
|
||||
private $listener;
|
||||
|
||||
/**
|
||||
* @var SessionInterface
|
||||
*/
|
||||
private $session;
|
||||
|
||||
protected function setUp()
|
||||
@ -58,6 +66,8 @@ class TestSessionListenerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testDoesNotDeleteCookieIfUsingSessionLifetime()
|
||||
{
|
||||
$this->sessionHasBeenStarted();
|
||||
|
||||
$params = session_get_cookie_params();
|
||||
session_set_cookie_params(0, $params['path'], $params['domain'], $params['secure'], $params['httponly']);
|
||||
|
||||
|
Reference in New Issue
Block a user