Bläddra i källkod

renamed some methods in the event dispatcher

Fabien Potencier 14 år sedan
förälder
incheckning
1219b98ec5
18 ändrade filer med 136 tillägg och 135 borttagningar
  1. 1 1
      src/Symfony/Bundle/AsseticBundle/Command/DumpCommand.php
  2. 2 2
      src/Symfony/Bundle/DoctrineBundle/DependencyInjection/Compiler/RegisterEventListenersAndSubscribersPass.php
  3. 2 2
      src/Symfony/Bundle/DoctrineMongoDBBundle/DependencyInjection/Compiler/RegisterEventListenersAndSubscribersPass.php
  4. 4 4
      src/Symfony/Bundle/FrameworkBundle/ContainerAwareEventDispatcher.php
  5. 1 1
      src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/RegisterKernelListenersPass.php
  6. 54 53
      src/Symfony/Component/EventDispatcher/EventDispatcher.php
  7. 16 16
      src/Symfony/Component/EventDispatcher/EventDispatcherInterface.php
  8. 5 5
      src/Symfony/Component/HttpKernel/HttpKernel.php
  9. 1 1
      src/Symfony/Component/Security/Http/Firewall/AbstractAuthenticationListener.php
  10. 1 1
      src/Symfony/Component/Security/Http/Firewall/AbstractPreAuthenticatedListener.php
  11. 1 1
      src/Symfony/Component/Security/Http/Firewall/ContextListener.php
  12. 1 1
      src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php
  13. 1 1
      src/Symfony/Component/Security/Http/Firewall/RememberMeListener.php
  14. 2 2
      src/Symfony/Component/Security/Http/Firewall/SwitchUserListener.php
  15. 29 29
      tests/Symfony/Tests/Component/EventDispatcher/EventDispatcherTest.php
  16. 6 6
      tests/Symfony/Tests/Component/HttpKernel/HttpCache/EsiListenerTest.php
  17. 4 4
      tests/Symfony/Tests/Component/HttpKernel/HttpKernelTest.php
  18. 5 5
      tests/Symfony/Tests/Component/HttpKernel/ResponseListenerTest.php

+ 1 - 1
src/Symfony/Bundle/AsseticBundle/Command/DumpCommand.php

@@ -48,7 +48,7 @@ class DumpCommand extends Command
 
         // notify an event so custom stream wrappers can be registered lazily
         $event = new WriteEvent($basePath);
-        $this->container->get('event_dispatcher')->dispatchEvent(Events::onAsseticWrite, $writeEvent);
+        $this->container->get('event_dispatcher')->dispatch(Events::onAsseticWrite, $writeEvent);
 
         if ($input->getOption('watch')) {
             return $this->watch($am, $basePath, $output, $this->container->getParameter('kernel.debug'));

+ 2 - 2
src/Symfony/Bundle/DoctrineBundle/DependencyInjection/Compiler/RegisterEventListenersAndSubscribersPass.php

@@ -32,7 +32,7 @@ class RegisterEventListenersAndSubscribersPass implements CompilerPassInterface
         );
 
         foreach ($subscribers as $id => $instances) {
-            $definition->addMethodCall('addEventSubscriber', array(new Reference($id)));
+            $definition->addMethodCall('addSubscriber', array(new Reference($id)));
         }
     }
 
@@ -52,7 +52,7 @@ class RegisterEventListenersAndSubscribersPass implements CompilerPassInterface
             }
 
             if (0 < count($events)) {
-                $definition->addMethodCall('addEventListener', array(
+                $definition->addMethodCall('addListener', array(
                     $events,
                     new Reference($listenerId),
                 ));

+ 2 - 2
src/Symfony/Bundle/DoctrineMongoDBBundle/DependencyInjection/Compiler/RegisterEventListenersAndSubscribersPass.php

@@ -29,7 +29,7 @@ class RegisterEventListenersAndSubscribersPass implements CompilerPassInterface
         );
 
         foreach ($subscribers as $id => $instances) {
-            $definition->addMethodCall('addEventSubscriber', array(new Reference($id)));
+            $definition->addMethodCall('addSubscriber', array(new Reference($id)));
         }
     }
 
@@ -49,7 +49,7 @@ class RegisterEventListenersAndSubscribersPass implements CompilerPassInterface
             }
 
             if (0 < count($events)) {
-                $definition->addMethodCall('addEventListener', array(
+                $definition->addMethodCall('addListener', array(
                     $events,
                     new Reference($listenerId),
                 ));

+ 4 - 4
src/Symfony/Bundle/FrameworkBundle/ContainerAwareEventDispatcher.php

@@ -56,7 +56,7 @@ class ContainerAwareEventDispatcher extends EventDispatcher
      *                              listener will be triggered in the chain.
      *                              Defaults to 0.
      */
-    public function addEventListenerService($events, $serviceId, $priority = 0)
+    public function addListenerService($events, $serviceId, $priority = 0)
     {
         if (!is_string($serviceId)) {
             throw new \InvalidArgumentException('Expected a string argument');
@@ -74,14 +74,14 @@ class ContainerAwareEventDispatcher extends EventDispatcher
      * Lazily loads listeners for this event from the dependency injection
      * container.
      */
-    public function dispatchEvent($eventName, Event $event = null)
+    public function dispatch($eventName, Event $event = null)
     {
         if (isset($this->listenerIds[$eventName])) {
             foreach ($this->listenerIds[$eventName] as $serviceId => $priority) {
-                $this->addEventListener($eventName, $this->container->get($serviceId), $priority);
+                $this->addListener($eventName, $this->container->get($serviceId), $priority);
             }
         }
 
-        parent::dispatchEvent($eventName, $event);
+        parent::dispatch($eventName, $event);
     }
 }

+ 1 - 1
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/RegisterKernelListenersPass.php

@@ -34,7 +34,7 @@ class RegisterKernelListenersPass implements CompilerPassInterface
                     throw new \InvalidArgumentException(sprintf('Service "%s" must define the "event" attribute on "kernel.listener" tags.', $id));
                 }
 
-                $definition->addMethodCall('addEventListenerService', array($event['event'], $id, $priority));
+                $definition->addMethodCall('addListenerService', array($event['event'], $id, $priority));
             }
         }
     }

+ 54 - 53
src/Symfony/Component/EventDispatcher/EventDispatcher.php

@@ -23,7 +23,8 @@
 namespace Symfony\Component\EventDispatcher;
 
 /**
- * The EventDispatcherInterface is the central point of Doctrine's event listener system.
+ * The EventDispatcherInterface is the central point of Symfony's event listener system.
+ *
  * Listeners are registered on the manager and events are dispatched through the
  * manager.
  *
@@ -65,9 +66,9 @@ class EventDispatcher implements EventDispatcherInterface
     private $sorted = array();
 
     /**
-     * @see EventDispatcherInterface::dispatchEvent
+     * @see EventDispatcherInterface::dispatch
      */
-    public function dispatchEvent($eventName, Event $event = null)
+    public function dispatch($eventName, Event $event = null)
     {
         if (isset($this->listeners[$eventName])) {
             if (null === $event) {
@@ -86,48 +87,6 @@ class EventDispatcher implements EventDispatcherInterface
         }
     }
 
-    /**
-     * Triggers the listener method for an event.
-     *
-     * This method can be overridden to add functionality that is executed
-     * for each listener.
-     *
-     * @param object $listener The event listener on which to invoke the listener method.
-     * @param string $eventName The name of the event to dispatch. The name of the event is
-     *                          the name of the method that is invoked on listeners.
-     * @param Event $event The event arguments to pass to the event handlers/listeners.
-     */
-    protected function triggerListener($listener, $eventName, Event $event)
-    {
-        if ($listener instanceof \Closure) {
-            $listener->__invoke($event);
-        } else {
-            $listener->$eventName($event);
-        }
-    }
-
-    /**
-     * Sorts the internal list of listeners for the given event by priority.
-     *
-     * Calling this method multiple times will not cause overhead unless you
-     * add new listeners. As long as no listener is added, the list for an
-     * event name won't be sorted twice.
-     *
-     * @param string $event The name of the event.
-     */
-    private function sortListeners($eventName)
-    {
-        if (!$this->sorted[$eventName]) {
-            $p = $this->priorities[$eventName];
-
-            uasort($this->listeners[$eventName], function ($a, $b) use ($p) {
-                return $p[spl_object_hash($b)] - $p[spl_object_hash($a)];
-            });
-
-            $this->sorted[$eventName] = true;
-        }
-    }
-
     /**
      * @see EventDispatcherInterface::getListeners
      */
@@ -155,9 +114,9 @@ class EventDispatcher implements EventDispatcherInterface
     }
 
     /**
-     * @see EventDispatcherInterface::addEventListener
+     * @see EventDispatcherInterface::addListener
      */
-    public function addEventListener($eventNames, $listener, $priority = 0)
+    public function addListener($eventNames, $listener, $priority = 0)
     {
         // Picks the hash code related to that listener
         $hash = spl_object_hash($listener);
@@ -176,9 +135,9 @@ class EventDispatcher implements EventDispatcherInterface
     }
 
     /**
-     * @see EventDispatcherInterface::removeEventListener
+     * @see EventDispatcherInterface::removeListener
      */
-    public function removeEventListener($eventNames, $listener)
+    public function removeListener($eventNames, $listener)
     {
         // Picks the hash code related to that listener
         $hash = spl_object_hash($listener);
@@ -193,10 +152,52 @@ class EventDispatcher implements EventDispatcherInterface
     }
 
     /**
-     * @see EventDispatcherInterface::addEventSubscriber
+     * @see EventDispatcherInterface::addSubscriber
      */
-    public function addEventSubscriber(EventSubscriberInterface $subscriber, $priority = 0)
+    public function addSubscriber(EventSubscriberInterface $subscriber, $priority = 0)
     {
-        $this->addEventListener($subscriber->getSubscribedEvents(), $subscriber, $priority);
+        $this->addListener($subscriber->getSubscribedEvents(), $subscriber, $priority);
+    }
+
+    /**
+     * Triggers the listener method for an event.
+     *
+     * This method can be overridden to add functionality that is executed
+     * for each listener.
+     *
+     * @param object $listener The event listener on which to invoke the listener method.
+     * @param string $eventName The name of the event to dispatch. The name of the event is
+     *                          the name of the method that is invoked on listeners.
+     * @param Event $event The event arguments to pass to the event handlers/listeners.
+     */
+    protected function triggerListener($listener, $eventName, Event $event)
+    {
+        if ($listener instanceof \Closure) {
+            $listener->__invoke($event);
+        } else {
+            $listener->$eventName($event);
+        }
+    }
+
+    /**
+     * Sorts the internal list of listeners for the given event by priority.
+     *
+     * Calling this method multiple times will not cause overhead unless you
+     * add new listeners. As long as no listener is added, the list for an
+     * event name won't be sorted twice.
+     *
+     * @param string $event The name of the event.
+     */
+    private function sortListeners($eventName)
+    {
+        if (!$this->sorted[$eventName]) {
+            $p = $this->priorities[$eventName];
+
+            uasort($this->listeners[$eventName], function ($a, $b) use ($p) {
+                return $p[spl_object_hash($b)] - $p[spl_object_hash($a)];
+            });
+
+            $this->sorted[$eventName] = true;
+        }
     }
-}
+}

+ 16 - 16
src/Symfony/Component/EventDispatcher/EventDispatcherInterface.php

@@ -12,7 +12,7 @@
 namespace Symfony\Component\EventDispatcher;
 
 /**
- * The EventDispatcherInterface is the central point of Doctrine's event listener system.
+ * The EventDispatcherInterface is the central point of Symfony's event listener system.
  * Listeners are registered on the manager and events are dispatched through the
  * manager.
  *
@@ -20,6 +20,17 @@ namespace Symfony\Component\EventDispatcher;
  */
 interface EventDispatcherInterface
 {
+    /**
+     * Dispatches an event to all registered listeners.
+     *
+     * @param string $eventName The name of the event to dispatch. The name of
+     *                          the event is the name of the method that is
+     *                          invoked on listeners.
+     * @param Event $event The event to pass to the event handlers/listeners.
+     *                     If not supplied, an empty Event instance is created.
+     */
+    function dispatch($eventName, Event $event = null);
+
     /**
      * Adds an event listener that listens on the specified events.
      *
@@ -29,7 +40,7 @@ interface EventDispatcherInterface
      *                          listener will be triggered in the chain.
      *                          Defaults to 0.
      */
-    function addEventListener($eventNames, $listener, $priority = 0);
+    function addListener($eventNames, $listener, $priority = 0);
 
     /**
      * Adds an event subscriber. The subscriber is asked for all the events he is
@@ -40,7 +51,7 @@ interface EventDispatcherInterface
      *                          listener will be triggered in the chain.
      *                          Defaults to 0.
      */
-    function addEventSubscriber(EventSubscriberInterface $subscriber, $priority = 0);
+    function addSubscriber(EventSubscriberInterface $subscriber, $priority = 0);
 
     /**
      * Removes an event listener from the specified events.
@@ -48,18 +59,7 @@ interface EventDispatcherInterface
      * @param string|array $eventNames The event(s) to remove a listener from.
      * @param object $listener The listener object to remove.
      */
-    function removeEventListener($eventNames, $listener);
-
-    /**
-     * Dispatches an event to all registered listeners.
-     *
-     * @param string $eventName The name of the event to dispatch. The name of
-     *                          the event is the name of the method that is
-     *                          invoked on listeners.
-     * @param Event $event The event to pass to the event handlers/listeners.
-     *                     If not supplied, an empty Event instance is created.
-     */
-    function dispatchEvent($eventName, Event $event = null);
+    function removeListener($eventNames, $listener);
 
     /**
      * Gets the listeners of a specific event or all listeners.
@@ -80,4 +80,4 @@ interface EventDispatcherInterface
      *                 otherwise.
      */
     function hasListeners($eventName);
-}
+}

+ 5 - 5
src/Symfony/Component/HttpKernel/HttpKernel.php

@@ -89,7 +89,7 @@ class HttpKernel implements HttpKernelInterface
     {
         // request
         $event = new GetResponseEvent($this, $request, $type);
-        $this->dispatcher->dispatchEvent(Events::onCoreRequest, $event);
+        $this->dispatcher->dispatch(Events::onCoreRequest, $event);
 
         if ($event->hasResponse()) {
             return $this->filterResponse($event->getResponse(), $request, $type);
@@ -101,7 +101,7 @@ class HttpKernel implements HttpKernelInterface
         }
 
         $event = new FilterControllerEvent($this, $controller, $request, $type);
-        $this->dispatcher->dispatchEvent(Events::filterCoreController, $event);
+        $this->dispatcher->dispatch(Events::filterCoreController, $event);
         $controller = $event->getController();
 
         // controller arguments
@@ -113,7 +113,7 @@ class HttpKernel implements HttpKernelInterface
         // view
         if (!$response instanceof Response) {
             $event = new GetResponseForControllerResultEvent($this, $request, $type, $response);
-            $this->dispatcher->dispatchEvent(Events::onCoreView, $event);
+            $this->dispatcher->dispatch(Events::onCoreView, $event);
 
             if ($event->hasResponse()) {
                 $response = $event->getResponse();
@@ -142,7 +142,7 @@ class HttpKernel implements HttpKernelInterface
     {
         $event = new FilterResponseEvent($this, $request, $type, $response);
 
-        $this->dispatcher->dispatchEvent(Events::filterCoreResponse, $event);
+        $this->dispatcher->dispatch(Events::filterCoreResponse, $event);
 
         return $event->getResponse();
     }
@@ -159,7 +159,7 @@ class HttpKernel implements HttpKernelInterface
     protected function handleException(\Exception $e, $request, $type)
     {
         $event = new GetResponseForExceptionEvent($this, $request, $type, $e);
-        $this->dispatcher->dispatchEvent(Events::onCoreException, $event);
+        $this->dispatcher->dispatch(Events::onCoreException, $event);
 
         if (!$event->hasResponse()) {
             throw $e;

+ 1 - 1
src/Symfony/Component/Security/Http/Firewall/AbstractAuthenticationListener.php

@@ -213,7 +213,7 @@ abstract class AbstractAuthenticationListener implements ListenerInterface
 
         if (null !== $this->dispatcher) {
             $loginEvent = new InteractiveLoginEvent($request, $token);
-            $this->dispatcher->dispatchEvent(Events::onSecurityInteractiveLogin, $loginEvent);
+            $this->dispatcher->dispatch(Events::onSecurityInteractiveLogin, $loginEvent);
         }
 
         if (null !== $this->successHandler) {

+ 1 - 1
src/Symfony/Component/Security/Http/Firewall/AbstractPreAuthenticatedListener.php

@@ -82,7 +82,7 @@ abstract class AbstractPreAuthenticatedListener implements ListenerInterface
 
             if (null !== $this->dispatcher) {
                 $loginEvent = new InteractiveLoginEvent($request, $token);
-                $this->dispatcher->dispatchEvent(Events::onSecurityInteractiveLogin, $loginEvent);
+                $this->dispatcher->dispatch(Events::onSecurityInteractiveLogin, $loginEvent);
             }
         } catch (AuthenticationException $failed) {
             $this->securityContext->setToken(null);

+ 1 - 1
src/Symfony/Component/Security/Http/Firewall/ContextListener.php

@@ -49,7 +49,7 @@ class ContextListener implements ListenerInterface
         $this->contextKey = $contextKey;
 
         if (null !== $dispatcher) {
-            $dispatcher->addEventListener(Events::onCoreResponse, $this);
+            $dispatcher->addListener(Events::onCoreResponse, $this);
         }
     }
 

+ 1 - 1
src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php

@@ -58,7 +58,7 @@ class ExceptionListener
      */
     public function register(EventDispatcherInterface $dispatcher)
     {
-        $dispatcher->addEventListener(Events::onCoreException, $this);
+        $dispatcher->addListener(Events::onCoreException, $this);
     }
 
     /**

+ 1 - 1
src/Symfony/Component/Security/Http/Firewall/RememberMeListener.php

@@ -79,7 +79,7 @@ class RememberMeListener implements ListenerInterface
 
             if (null !== $this->dispatcher) {
                 $loginEvent = new InteractiveLoginEvent($request, $token);
-                $this->dispatcher->dispatchEvent(Events::onSecurityInteractiveLogin, $loginEvent);
+                $this->dispatcher->dispatch(Events::onSecurityInteractiveLogin, $loginEvent);
             }
 
             if (null !== $this->logger) {

+ 2 - 2
src/Symfony/Component/Security/Http/Firewall/SwitchUserListener.php

@@ -131,7 +131,7 @@ class SwitchUserListener implements ListenerInterface
 
         if (null !== $this->dispatcher) {
             $switchEvent = new SwitchUserEvent($request, $token->getUser());
-            $this->dispatcher->dispatchEvent(Events::onSecuritySwitchUser, $switchEvent);
+            $this->dispatcher->dispatch(Events::onSecuritySwitchUser, $switchEvent);
         }
 
         return $token;
@@ -152,7 +152,7 @@ class SwitchUserListener implements ListenerInterface
 
         if (null !== $this->dispatcher) {
             $switchEvent = new SwitchUserEvent($request, $original->getUser());
-            $this->dispatcher->dispatchEvent(Events::onSecuritySwitchUser, $switchEvent);
+            $this->dispatcher->dispatch(Events::onSecuritySwitchUser, $switchEvent);
         }
 
         return $original;

+ 29 - 29
tests/Symfony/Tests/Component/EventDispatcher/EventDispatcherTest.php

@@ -40,9 +40,9 @@ class EventDispatcherTest extends \PHPUnit_Framework_TestCase
         $this->assertFalse($this->dispatcher->hasListeners(self::postFoo));
     }
 
-    public function testAddEventListener()
+    public function testAddListener()
     {
-        $this->dispatcher->addEventListener(array('preFoo', 'postFoo'), $this->listener);
+        $this->dispatcher->addListener(array('preFoo', 'postFoo'), $this->listener);
         $this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
         $this->assertTrue($this->dispatcher->hasListeners(self::postFoo));
         $this->assertEquals(1, count($this->dispatcher->getListeners(self::preFoo)));
@@ -56,9 +56,9 @@ class EventDispatcherTest extends \PHPUnit_Framework_TestCase
         $listener2 = new TestEventListener();
         $listener3 = new TestEventListener();
 
-        $this->dispatcher->addEventListener('preFoo', $listener1, -10);
-        $this->dispatcher->addEventListener('preFoo', $listener2);
-        $this->dispatcher->addEventListener('preFoo', $listener3, 10);
+        $this->dispatcher->addListener('preFoo', $listener1, -10);
+        $this->dispatcher->addListener('preFoo', $listener2);
+        $this->dispatcher->addListener('preFoo', $listener3, 10);
 
         $expected = array(
             spl_object_hash($listener3) => $listener3,
@@ -78,12 +78,12 @@ class EventDispatcherTest extends \PHPUnit_Framework_TestCase
         $listener5 = new TestEventListener();
         $listener6 = new TestEventListener();
 
-        $this->dispatcher->addEventListener('preFoo', $listener1, -10);
-        $this->dispatcher->addEventListener('preFoo', $listener2);
-        $this->dispatcher->addEventListener('preFoo', $listener3, 10);
-        $this->dispatcher->addEventListener('postFoo', $listener4, -10);
-        $this->dispatcher->addEventListener('postFoo', $listener5);
-        $this->dispatcher->addEventListener('postFoo', $listener6, 10);
+        $this->dispatcher->addListener('preFoo', $listener1, -10);
+        $this->dispatcher->addListener('preFoo', $listener2);
+        $this->dispatcher->addListener('preFoo', $listener3, 10);
+        $this->dispatcher->addListener('postFoo', $listener4, -10);
+        $this->dispatcher->addListener('postFoo', $listener5);
+        $this->dispatcher->addListener('postFoo', $listener6, 10);
 
         $expected = array(
             'preFoo' => array(
@@ -101,22 +101,22 @@ class EventDispatcherTest extends \PHPUnit_Framework_TestCase
         $this->assertSame($expected, $this->dispatcher->getListeners());
     }
 
-    public function testDispatchEvent()
+    public function testDispatch()
     {
-        $this->dispatcher->addEventListener(array('preFoo', 'postFoo'), $this->listener);
-        $this->dispatcher->dispatchEvent(self::preFoo);
+        $this->dispatcher->addListener(array('preFoo', 'postFoo'), $this->listener);
+        $this->dispatcher->dispatch(self::preFoo);
         $this->assertTrue($this->listener->preFooInvoked);
         $this->assertFalse($this->listener->postFooInvoked);
     }
 
-    public function testDispatchEventForClosure()
+    public function testDispatchForClosure()
     {
         $invoked = 0;
         $listener = function () use (&$invoked) {
             $invoked++;
         };
-        $this->dispatcher->addEventListener(array('preFoo', 'postFoo'), $listener);
-        $this->dispatcher->dispatchEvent(self::preFoo);
+        $this->dispatcher->addListener(array('preFoo', 'postFoo'), $listener);
+        $this->dispatcher->dispatch(self::preFoo);
         $this->assertEquals(1, $invoked);
     }
 
@@ -127,9 +127,9 @@ class EventDispatcherTest extends \PHPUnit_Framework_TestCase
         // postFoo() stops the propagation, so only one listener should
         // be executed
         // Manually set priority to enforce $this->listener to be called first
-        $this->dispatcher->addEventListener('postFoo', $this->listener, 10);
-        $this->dispatcher->addEventListener('postFoo', $otherListener);
-        $this->dispatcher->dispatchEvent(self::postFoo);
+        $this->dispatcher->addListener('postFoo', $this->listener, 10);
+        $this->dispatcher->addListener('postFoo', $otherListener);
+        $this->dispatcher->dispatch(self::postFoo);
         $this->assertTrue($this->listener->postFooInvoked);
         $this->assertFalse($otherListener->postFooInvoked);
     }
@@ -146,25 +146,25 @@ class EventDispatcherTest extends \PHPUnit_Framework_TestCase
         $listener3 = function () use (&$invoked) {
             $invoked[] = '3';
         };
-        $this->dispatcher->addEventListener('preFoo', $listener1, -10);
-        $this->dispatcher->addEventListener('preFoo', $listener2);
-        $this->dispatcher->addEventListener('preFoo', $listener3, 10);
-        $this->dispatcher->dispatchEvent(self::preFoo);
+        $this->dispatcher->addListener('preFoo', $listener1, -10);
+        $this->dispatcher->addListener('preFoo', $listener2);
+        $this->dispatcher->addListener('preFoo', $listener3, 10);
+        $this->dispatcher->dispatch(self::preFoo);
         $this->assertEquals(array('3', '2', '1'), $invoked);
     }
 
-    public function testRemoveEventListener()
+    public function testRemoveListener()
     {
-        $this->dispatcher->addEventListener(array('preBar'), $this->listener);
+        $this->dispatcher->addListener(array('preBar'), $this->listener);
         $this->assertTrue($this->dispatcher->hasListeners(self::preBar));
-        $this->dispatcher->removeEventListener(array('preBar'), $this->listener);
+        $this->dispatcher->removeListener(array('preBar'), $this->listener);
         $this->assertFalse($this->dispatcher->hasListeners(self::preBar));
     }
 
-    public function testAddEventSubscriber()
+    public function testAddSubscriber()
     {
         $eventSubscriber = new TestEventSubscriber();
-        $this->dispatcher->addEventSubscriber($eventSubscriber);
+        $this->dispatcher->addSubscriber($eventSubscriber);
         $this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
         $this->assertTrue($this->dispatcher->hasListeners(self::postFoo));
     }

+ 6 - 6
tests/Symfony/Tests/Component/HttpKernel/HttpCache/EsiListenerTest.php

@@ -29,9 +29,9 @@ class EsiListenerTest extends \PHPUnit_Framework_TestCase
         $response = new Response('foo <esi:include src="" />');
         $listener = new EsiListener(new Esi());
 
-        $dispatcher->addEventListener(Events::filterCoreResponse, $listener);
+        $dispatcher->addListener(Events::filterCoreResponse, $listener);
         $event = new FilterResponseEvent($kernel, new Request(), HttpKernelInterface::SUB_REQUEST, $response);
-        $dispatcher->dispatchEvent(Events::filterCoreResponse, $event);
+        $dispatcher->dispatch(Events::filterCoreResponse, $event);
 
         $this->assertEquals('', $event->getResponse()->headers->get('Surrogate-Control'));
     }
@@ -43,9 +43,9 @@ class EsiListenerTest extends \PHPUnit_Framework_TestCase
         $response = new Response('foo <esi:include src="" />');
         $listener = new EsiListener(new Esi());
 
-        $dispatcher->addEventListener(Events::filterCoreResponse, $listener);
+        $dispatcher->addListener(Events::filterCoreResponse, $listener);
         $event = new FilterResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response);
-        $dispatcher->dispatchEvent(Events::filterCoreResponse, $event);
+        $dispatcher->dispatch(Events::filterCoreResponse, $event);
 
         $this->assertEquals('content="ESI/1.0"', $event->getResponse()->headers->get('Surrogate-Control'));
     }
@@ -57,9 +57,9 @@ class EsiListenerTest extends \PHPUnit_Framework_TestCase
         $response = new Response('foo');
         $listener = new EsiListener(new Esi());
 
-        $dispatcher->addEventListener(Events::filterCoreResponse, $listener);
+        $dispatcher->addListener(Events::filterCoreResponse, $listener);
         $event = new FilterResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response);
-        $dispatcher->dispatchEvent(Events::filterCoreResponse, $event);
+        $dispatcher->dispatch(Events::filterCoreResponse, $event);
 
         $this->assertEquals('', $event->getResponse()->headers->get('Surrogate-Control'));
     }

+ 4 - 4
tests/Symfony/Tests/Component/HttpKernel/HttpKernelTest.php

@@ -43,7 +43,7 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase
     public function testHandleWhenControllerThrowsAnExceptionAndRawIsFalse()
     {
         $dispatcher = new EventDispatcher();
-        $dispatcher->addEventListener(Events::onCoreException, function ($event)
+        $dispatcher->addListener(Events::onCoreException, function ($event)
         {
             $event->setResponse(new Response($event->getException()->getMessage()));
         });
@@ -56,7 +56,7 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase
     public function testHandleWhenAListenerReturnsAResponse()
     {
         $dispatcher = new EventDispatcher();
-        $dispatcher->addEventListener(Events::onCoreRequest, function ($event)
+        $dispatcher->addListener(Events::onCoreRequest, function ($event)
         {
             $event->setResponse(new Response('hello'));
         });
@@ -102,7 +102,7 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase
     public function testHandleWhenControllerDoesNotReturnAResponseButAViewIsRegistered()
     {
         $dispatcher = new EventDispatcher();
-        $dispatcher->addEventListener(Events::onCoreView, function ($event)
+        $dispatcher->addListener(Events::onCoreView, function ($event)
         {
             $event->setResponse(new Response($event->getControllerResult()));
         });
@@ -114,7 +114,7 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase
     public function testHandleWithAResponseListener()
     {
         $dispatcher = new EventDispatcher();
-        $dispatcher->addEventListener(Events::filterCoreResponse, function ($event)
+        $dispatcher->addListener(Events::filterCoreResponse, function ($event)
         {
             $event->setResponse(new Response('foo'));
         });

+ 5 - 5
tests/Symfony/Tests/Component/HttpKernel/ResponseListenerTest.php

@@ -29,7 +29,7 @@ class ResponseListenerTest extends \PHPUnit_Framework_TestCase
     {
         $this->dispatcher = new EventDispatcher();
         $listener = new ResponseListener('UTF-8');
-        $this->dispatcher->addEventListener(Events::filterCoreResponse, $listener);
+        $this->dispatcher->addListener(Events::filterCoreResponse, $listener);
 
         $this->kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
 
@@ -39,7 +39,7 @@ class ResponseListenerTest extends \PHPUnit_Framework_TestCase
         $response = new Response('foo');
 
         $event = new FilterResponseEvent($this->kernel, new Request(), HttpKernelInterface::SUB_REQUEST, $response);
-        $this->dispatcher->dispatchEvent(Events::filterCoreResponse, $event);
+        $this->dispatcher->dispatch(Events::filterCoreResponse, $event);
 
         $this->assertEquals('', $event->getResponse()->headers->get('content-type'));
     }
@@ -50,7 +50,7 @@ class ResponseListenerTest extends \PHPUnit_Framework_TestCase
         $response->headers->set('Content-Type', 'text/plain');
 
         $event = new FilterResponseEvent($this->kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response);
-        $this->dispatcher->dispatchEvent(Events::filterCoreResponse, $event);
+        $this->dispatcher->dispatch(Events::filterCoreResponse, $event);
 
         $this->assertEquals('text/plain', $event->getResponse()->headers->get('content-type'));
     }
@@ -60,7 +60,7 @@ class ResponseListenerTest extends \PHPUnit_Framework_TestCase
         $response = new Response('foo');
 
         $event = new FilterResponseEvent($this->kernel, Request::create('/'), HttpKernelInterface::MASTER_REQUEST, $response);
-        $this->dispatcher->dispatchEvent(Events::filterCoreResponse, $event);
+        $this->dispatcher->dispatch(Events::filterCoreResponse, $event);
 
         $this->assertEquals('', $event->getResponse()->headers->get('content-type'));
     }
@@ -72,7 +72,7 @@ class ResponseListenerTest extends \PHPUnit_Framework_TestCase
         $request->setRequestFormat('json');
 
         $event = new FilterResponseEvent($this->kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response);
-        $this->dispatcher->dispatchEvent(Events::filterCoreResponse, $event);
+        $this->dispatcher->dispatch(Events::filterCoreResponse, $event);
 
         $this->assertEquals('application/json', $event->getResponse()->headers->get('content-type'));
     }