Notifies all listeners of a given event.
public notify ( Symfony\Component\EventDispatcher\Event $event ) : Symfony\Component\EventDispatcher\Event | ||
$event | Symfony\Component\EventDispatcher\Event | An Event instance |
return | Symfony\Component\EventDispatcher\Event | The Event instance |
public function testNotify() { $listener = new Listener(); $dispatcher = new EventDispatcher(); $dispatcher->connect('foo', array($listener, 'listenToFoo')); $dispatcher->connect('foo', array($listener, 'listenToFooBis')); $e = $dispatcher->notify($event = new Event(new \stdClass(), 'foo')); $this->assertEquals('listenToFoolistenToFooBis', $listener->getValue(), '->notify() notifies all registered listeners in order'); $listener->reset(); $dispatcher = new EventDispatcher(); $dispatcher->connect('foo', array($listener, 'listenToFooBis')); $dispatcher->connect('foo', array($listener, 'listenToFoo')); $dispatcher->notify(new Event(new \stdClass(), 'foo')); $this->assertEquals('listenToFooBislistenToFoo', $listener->getValue(), '->notify() notifies all registered listeners in order'); }