public function testParamsSetterAndGetter() { $params = array('foo' => 'bar'); $event = new Event(); $event->setParams($params); $params = $event->getParams(); $this->assertTrue(is_array($params)); $this->assertArrayHasKey('foo', $params); $this->assertEquals('bar', $params['foo']); }
public function testPrioritizationOfListeners() { $eventManager = EventManager::getInstance(); $eventManager->listen('a', function ($event) { $params = $event->getParams(); $_SERVER['event_whatever'] = $params['bar']; }, 2); $eventManager->listen('a', function ($event) { $params = $event->getParams(); $_SERVER['event_whatever'] = $params['baz']; }, 3); $event = new Event(); $event->setParams(array('bar' => 'to eat', 'baz' => 'to bite')); $eventManager->trigger('a', $event); $this->assertEquals('to eat', $_SERVER['event_whatever']); }
public function bar(Event $event) { $params = $event->getParams(); $_SERVER['event_foobar'] = $params['foobar']; }