summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabien Potencier <fabien.potencier@gmail.com>2015-02-12 09:47:54 +0100
committerFabien Potencier <fabien.potencier@gmail.com>2015-02-12 09:47:54 +0100
commit1becbbdab19283e5c19eb8072965865a60e33876 (patch)
treefc1f02ca945567c26bb9cbd5c0572ff4df5307f2
parent2f1aeb2cdba0ee1809dab7ec0d2cafaaa7100a45 (diff)
parent6fa94f258d7739d5b5c6063716725204c6745a87 (diff)
downloadsymfony-security-1becbbdab19283e5c19eb8072965865a60e33876.zip
symfony-security-1becbbdab19283e5c19eb8072965865a60e33876.tar.gz
symfony-security-1becbbdab19283e5c19eb8072965865a60e33876.tar.bz2
Merge branch '2.7'
* 2.7: (26 commits) removed Propel bridge from Symfony Core [2.7] Added deprecation warning for get request service in controller [Serializer] Normalizers can serialize collections and scalars [FrameworkBundle] Fix title and placeholder rendering in php form templates. [Process] added a deprecation notice [TwigBridge] Removed duplicated code from TwigRenderer [Translator][Logging] implement TranslatorBagInterface. 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. “console help” ignores --raw option Fix form icon position in web profiler [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 ... Conflicts: composer.json src/Symfony/Bridge/Propel1/composer.json src/Symfony/Bridge/Twig/composer.json src/Symfony/Component/Console/Tests/Helper/LegacyTableHelperTest.php
-rw-r--r--Http/Firewall/ContextListener.php3
-rw-r--r--Http/Tests/Firewall/ContextListenerTest.php36
-rw-r--r--README.md2
3 files changed, 37 insertions, 4 deletions
diff --git a/Http/Firewall/ContextListener.php b/Http/Firewall/ContextListener.php
index 8df0d34..013586c 100644
--- a/Http/Firewall/ContextListener.php
+++ b/Http/Firewall/ContextListener.php
@@ -115,6 +115,9 @@ class ContextListener implements ListenerInterface
return;
}
+ $this->dispatcher->removeListener(KernelEvents::RESPONSE, array($this, 'onKernelResponse'));
+ $this->registered = false;
+
$request = $event->getRequest();
$session = $request->getSession();
diff --git a/Http/Tests/Firewall/ContextListenerTest.php b/Http/Tests/Firewall/ContextListenerTest.php
index cb9685a..ae1199a 100644
--- a/Http/Tests/Firewall/ContextListenerTest.php
+++ b/Http/Tests/Firewall/ContextListenerTest.php
@@ -21,6 +21,7 @@ use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Http\Firewall\ContextListener;
+use Symfony\Component\EventDispatcher\EventDispatcher;
class ContextListenerTest extends \PHPUnit_Framework_TestCase
{
@@ -99,7 +100,7 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase
new Response()
);
- $listener = new ContextListener($tokenStorage, array(), 'session');
+ $listener = new ContextListener($tokenStorage, array(), 'session', null, new EventDispatcher());
$listener->onKernelResponse($event);
$this->assertTrue($session->isStarted());
@@ -118,7 +119,7 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase
new Response()
);
- $listener = new ContextListener(new TokenStorage(), array(), 'session');
+ $listener = new ContextListener(new TokenStorage(), array(), 'session', null, new EventDispatcher());
$listener->onKernelResponse($event);
$this->assertFalse($session->isStarted());
@@ -190,6 +191,35 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase
$listener->handle($event);
}
+ public function testOnKernelResponseListenerRemovesItself()
+ {
+ $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
+ $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
+ $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\FilterResponseEvent')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $listener = new ContextListener($tokenStorage, 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('isMasterRequest')
+ ->will($this->returnValue(true));
+ $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');
@@ -229,7 +259,7 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase
new Response()
);
- $listener = new ContextListener($tokenStorage, array(), 'session');
+ $listener = new ContextListener($tokenStorage, array(), 'session', null, new EventDispatcher());
$listener->onKernelResponse($event);
return $session;
diff --git a/README.md b/README.md
index 32894b1..c3a6049 100644
--- a/README.md
+++ b/README.md
@@ -19,5 +19,5 @@ Tests
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/Security/
- $ composer.phar install
+ $ composer install
$ phpunit