/** * @covers Imbo\EventManager\EventManager::getHandlerInstance */ public function testCanInjectParamsInConstructor() { $listenerClassName = __NAMESPACE__ . '\\Listener'; $this->manager->addEventHandler('someHandler', $listenerClassName, array('param')); $this->manager->addCallbacks('someHandler', $listenerClassName::getSubscribedEvents()); $this->expectOutputString('a:1:{i:0;s:5:"param";}'); $this->manager->trigger('getParams'); }
/** * @see https://github.com/imbo/imbo/issues/251 * * This test is best run with "In the Ghetto" blasting on the stereo */ public function testHasHigherPriorityThanTheStatsResource() { $statsAccess = new StatsAccess(); $statsResource = new StatsResource(); $eventManager = new EventManager(); $eventManager->addEventHandler('statsAccess', $statsAccess); $eventManager->addCallbacks('statsAccess', StatsAccess::getSubscribedEvents()); $eventManager->addEventHandler('statsResource', $statsResource); $eventManager->addCallbacks('statsResource', StatsResource::getSubscribedEvents()); $callbacks = new ReflectionProperty($eventManager, 'callbacks'); $callbacks->setAccessible(true); $handlersForGet = $callbacks->getValue($eventManager)['stats.get']; $handlersForHead = $callbacks->getValue($eventManager)['stats.head']; $this->assertSame($statsAccess, $eventManager->getHandlerInstance($handlersForGet->extract()['handler'])); $this->assertSame($statsResource, $eventManager->getHandlerInstance($handlersForGet->extract()['handler'])); $this->assertSame($statsAccess, $eventManager->getHandlerInstance($handlersForHead->extract()['handler'])); $this->assertSame($statsResource, $eventManager->getHandlerInstance($handlersForHead->extract()['handler'])); }