diff options
author | Fabien Potencier <fabien.potencier@gmail.com> | 2013-02-04 17:20:47 +0100 |
---|---|---|
committer | Fabien Potencier <fabien.potencier@gmail.com> | 2013-02-04 18:59:58 +0100 |
commit | 1c556ad72cfb835726456d1ef63664a105b9ddf2 (patch) | |
tree | 63d696bca929dad3db63c3dd0763954f66372437 /Tests/Http | |
parent | 7561b128e4d69b9a3d801209970a780c3d416b01 (diff) | |
download | symfony-security-1c556ad72cfb835726456d1ef63664a105b9ddf2.zip symfony-security-1c556ad72cfb835726456d1ef63664a105b9ddf2.tar.gz symfony-security-1c556ad72cfb835726456d1ef63664a105b9ddf2.tar.bz2 |
[Security] fixed session creation when none is needed (closes #6917)
Diffstat (limited to 'Tests/Http')
-rw-r--r-- | Tests/Http/Firewall/ContextListenerTest.php | 58 |
1 files changed, 30 insertions, 28 deletions
diff --git a/Tests/Http/Firewall/ContextListenerTest.php b/Tests/Http/Firewall/ContextListenerTest.php index 620aa29..2a8a28e 100644 --- a/Tests/Http/Firewall/ContextListenerTest.php +++ b/Tests/Http/Firewall/ContextListenerTest.php @@ -82,36 +82,12 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase $this->assertFalse($session->has('_security_session')); } - protected function runSessionOnKernelResponse($newToken, $original = null) - { - $session = new Session(new MockArraySessionStorage()); - - if ($original !== null) { - $session->set('_security_session', $original); - } - - $this->securityContext->setToken($newToken); - - $request = new Request(); - $request->setSession($session); - - $event = new FilterResponseEvent( - $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'), - $request, - HttpKernelInterface::MASTER_REQUEST, - new Response() - ); - - $listener = new ContextListener($this->securityContext, array(), 'session'); - $listener->onKernelResponse($event); - - return $session; - } - public function testOnKernelResponseWithoutSession() { $this->securityContext->setToken(new UsernamePasswordToken('test1', 'pass1', 'phpunit')); $request = new Request(); + $session = new Session(new MockArraySessionStorage()); + $request->setSession($session); $event = new FilterResponseEvent( $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'), @@ -123,7 +99,7 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase $listener = new ContextListener($this->securityContext, array(), 'session'); $listener->onKernelResponse($event); - $this->assertFalse($request->hasSession()); + $this->assertFalse($session->isStarted()); } /** @@ -168,4 +144,30 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase array(null), ); } -} + + protected function runSessionOnKernelResponse($newToken, $original = null) + { + $session = new Session(new MockArraySessionStorage()); + + if ($original !== null) { + $session->set('_security_session', $original); + } + + $this->securityContext->setToken($newToken); + + $request = new Request(); + $request->setSession($session); + $request->cookies->set('MOCKSESSID', true); + + $event = new FilterResponseEvent( + $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'), + $request, + HttpKernelInterface::MASTER_REQUEST, + new Response() + ); + + $listener = new ContextListener($this->securityContext, array(), 'session'); + $listener->onKernelResponse($event); + + return $session; + }} |