public function testReset() { $event = new Event('newType'); $target = $this->getMock('\\aw\\events\\EventDispatcher'); $event->preventDefault(); Event::reset($event, $target); $this->assertFalse($event->isDefaultPrevented()); $this->assertSame($target, $event->getTarget()); $this->assertSame($target, $event->target); }
public function dispatchEvent($event) : bool { $result = false; if ($event instanceof IEvent) { $eventType = $event->getType(); } else { $eventType = (string) $event; $event = new Event($eventType); } if ($this->hasEventListener($eventType)) { if ($event instanceof Event) { Event::reset($event, $this); } foreach ($this->_listeners->getEventIterator($eventType) as $listener) { $listener($event); $result = true; } } return $result; }