summaryrefslogtreecommitdiffstats
path: root/Tests/Http/Firewall
diff options
context:
space:
mode:
authorChristian Flothmann <christian.flothmann@xabbuh.de>2015-11-05 23:29:27 +0100
committerFabien Potencier <fabien.potencier@gmail.com>2015-11-23 11:04:06 +0100
commitcc98e8c84c84b9ffda2544762c41bfee8e192b72 (patch)
treef5292f769d3faa65ba6f55d51e6f23b196602eb4 /Tests/Http/Firewall
parent1dabcc78193413d90a6a1eeaaf50764b67ac61af (diff)
downloadsymfony-security-cc98e8c84c84b9ffda2544762c41bfee8e192b72.zip
symfony-security-cc98e8c84c84b9ffda2544762c41bfee8e192b72.tar.gz
symfony-security-cc98e8c84c84b9ffda2544762c41bfee8e192b72.tar.bz2
migrate session after remember me authentication
Diffstat (limited to 'Tests/Http/Firewall')
-rw-r--r--Tests/Http/Firewall/RememberMeListenerTest.php63
1 files changed, 63 insertions, 0 deletions
diff --git a/Tests/Http/Firewall/RememberMeListenerTest.php b/Tests/Http/Firewall/RememberMeListenerTest.php
index 067cacb..ad96243 100644
--- a/Tests/Http/Firewall/RememberMeListenerTest.php
+++ b/Tests/Http/Firewall/RememberMeListenerTest.php
@@ -138,6 +138,69 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase
$listener->handle($event);
}
+ public function testSessionStrategy()
+ {
+ list($listener, $tokenStorage, $service, $manager) = $this->getListener(false, true, true);
+
+ $tokenStorage
+ ->expects($this->once())
+ ->method('getToken')
+ ->will($this->returnValue(null))
+ ;
+
+ $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $service
+ ->expects($this->once())
+ ->method('autoLogin')
+ ->will($this->returnValue($token))
+ ;
+
+ $tokenStorage
+ ->expects($this->once())
+ ->method('setToken')
+ ->with($this->equalTo($token))
+ ;
+
+ $manager
+ ->expects($this->once())
+ ->method('authenticate')
+ ->will($this->returnValue($token))
+ ;
+
+ $session = $this->getMock('\Symfony\Component\HttpFoundation\Session\SessionInterface');
+ $session
+ ->expects($this->once())
+ ->method('isStarted')
+ ->will($this->returnValue(true))
+ ;
+ $session
+ ->expects($this->once())
+ ->method('migrate')
+ ;
+
+ $request = $this->getMock('\Symfony\Component\HttpFoundation\Request');
+ $request
+ ->expects($this->any())
+ ->method('hasSession')
+ ->will($this->returnValue(true))
+ ;
+
+ $request
+ ->expects($this->any())
+ ->method('getSession')
+ ->will($this->returnValue($session))
+ ;
+
+ $event = $this->getGetResponseEvent();
+ $event
+ ->expects($this->once())
+ ->method('getRequest')
+ ->will($this->returnValue($request))
+ ;
+
+ $listener->handle($event);
+ }
+
protected function getGetResponseEvent()
{
return $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false);