diff options
author | Fabien Potencier <fabien.potencier@gmail.com> | 2015-02-11 08:12:14 +0100 |
---|---|---|
committer | Fabien Potencier <fabien.potencier@gmail.com> | 2015-02-11 08:12:14 +0100 |
commit | a8d995fac4ccf99e34db97ea252cc993382ac83e (patch) | |
tree | a7a24f3e3e488d0d7bb6c5656e20ee35dd7056f1 /Http/Tests/Firewall | |
parent | 3ab3e7fe1a03c043d03d6bac5666e9cbb51caa16 (diff) | |
parent | 41890dcab00f2e1de2080472bd9d57e242e3db76 (diff) | |
download | symfony-security-a8d995fac4ccf99e34db97ea252cc993382ac83e.zip symfony-security-a8d995fac4ccf99e34db97ea252cc993382ac83e.tar.gz symfony-security-a8d995fac4ccf99e34db97ea252cc993382ac83e.tar.bz2 |
Merge branch '2.3' into 2.6
* 2.3:
[FrameworkBundle] Fix title and placeholder rendering in php form templates.
RequestDataCollector - small fix
renamed composer.phar to composer to be consistent with the Symfony docs
[FrameworkBundle] bumped min version of Routing to 2.3
removed composer --dev option everywhere
fixed a test
[Console] Fixed output bug, if escaped string in a formatted string.
[Security] Remove ContextListener's onKernelResponse listener as it is used
Revert "minor #12652 [HttpFoundation] [Hackday] #9942 test: Request::getContent() for null value (skler)"
Revert "fixed assertion"
fixed assertion
[HttpFoundation] [Hackday] #9942 test: Request::getContent() for null value
fixed URL
Add reference to documentation in FormEvents phpdocs
[YAML] Fix one-liners to work with multiple new lines
Keep "pre" meaning for var_dump quick-and-dirty debug
[Console][Table] Fix cell padding with multi-byte
Conflicts:
src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/widget_attributes.html.php
src/Symfony/Bundle/FrameworkBundle/composer.json
src/Symfony/Component/Console/Helper/TableHelper.php
Diffstat (limited to 'Http/Tests/Firewall')
-rw-r--r-- | Http/Tests/Firewall/ContextListenerTest.php | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/Http/Tests/Firewall/ContextListenerTest.php b/Http/Tests/Firewall/ContextListenerTest.php index 90af07e..b06eda9 100644 --- a/Http/Tests/Firewall/ContextListenerTest.php +++ b/Http/Tests/Firewall/ContextListenerTest.php @@ -22,6 +22,7 @@ use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; use Symfony\Component\Security\Core\SecurityContext; use Symfony\Component\Security\Http\Firewall\ContextListener; +use Symfony\Component\EventDispatcher\EventDispatcher; class ContextListenerTest extends \PHPUnit_Framework_TestCase { @@ -112,7 +113,7 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase new Response() ); - $listener = new ContextListener($this->securityContext, array(), 'session'); + $listener = new ContextListener($this->securityContext, array(), 'session', null, new EventDispatcher()); $listener->onKernelResponse($event); $this->assertTrue($session->isStarted()); @@ -131,7 +132,7 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase new Response() ); - $listener = new ContextListener($this->securityContext, array(), 'session'); + $listener = new ContextListener($this->securityContext, array(), 'session', null, new EventDispatcher()); $listener->onKernelResponse($event); $this->assertFalse($session->isStarted()); @@ -203,6 +204,35 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase $listener->handle($event); } + public function testOnKernelResponseListenerRemovesItself() + { + $context = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface'); + $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\FilterResponseEvent') + ->disableOriginalConstructor() + ->getMock(); + + $listener = new ContextListener($context, array(), 'key123', null, $dispatcher); + + $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); + $request->expects($this->any()) + ->method('hasSession') + ->will($this->returnValue(true)); + + $event->expects($this->any()) + ->method('getRequestType') + ->will($this->returnValue(HttpKernelInterface::MASTER_REQUEST)); + $event->expects($this->any()) + ->method('getRequest') + ->will($this->returnValue($request)); + + $dispatcher->expects($this->once()) + ->method('removeListener') + ->with(KernelEvents::RESPONSE, array($listener, 'onKernelResponse')); + + $listener->onKernelResponse($event); + } + public function testHandleRemovesTokenIfNoPreviousSessionWasFound() { $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); @@ -241,7 +271,7 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase new Response() ); - $listener = new ContextListener($this->securityContext, array(), 'session'); + $listener = new ContextListener($this->securityContext, array(), 'session', null, new EventDispatcher()); $listener->onKernelResponse($event); return $session; |