/** * @param $event_name * @param Event $event * @return \Symfony\Component\EventDispatcher\Event */ public function dispatchEvent($event_name, Event $event = null) { if (is_null($event)) { $event = Event::make(); } return $this->dispatch($event_name, $event); }
public function testDispatchEvent() { /** @var EventDispatcher $event_dispatcher */ $event_dispatcher = new EventDispatcher(); $function = function (Event $event) { $this->assertInstanceOf('Huruk\\EventDispatcher\\Event', $event); if (isset($event['foo'])) { $this->assertEquals('bar', $event['foo']); } }; $event_dispatcher->listen('foo', $function); //Trigger $event_dispatcher->dispatchEvent('foo'); $event_dispatcher->dispatchEvent('foo', Event::make(array('foo' => 'bar'))); }
public function testFactory() { $data = array('foo' => 'bar'); $event = Event::make($data); $this->assertEquals($data, $event->getData()); }