public function testStopPropagation() { $eventManager = new EventManager(); $event = new Event('event1'); $event->setParam('count', 0); $eventManager->addListener('event1', function ($e) { $count = $e->getParam('count', 0); $e->setParam('count', $count + 1); }, 2); $eventManager->addListener('event1', function ($e) { $count = $e->getParam('count', 0); $e->setParam('count', $count + 1); }, 2); $eventManager->addListener('event1', function ($e) { $count = $e->getParam('count', 0); $e->setParam('count', $count + 1); }, 1); $eventManager->addListener('event1', function ($e) { $count = $e->getParam('count', 0); $e->setParam('count', $count + 1); $e->stopPropagation(); }); $eventManager->trigger($event); $this->assertEquals($event->getParam('count'), 2); }
public function testSetEventManager() { $eventManager = new EventManager(); $eventManager->addListener('my', function () { // ... }); $this->provider->setEventManager($eventManager); $newEm = $this->provider->getEventManager(); $this->assertTrue($newEm->hasListeners('my')); }