public function testSendResponseTriggersSendResponseEvent() { $listener = new SendResponseListener(); $result = array(); $listener->getEventManager()->attach('sendResponse', function ($e) use(&$result) { $result['target'] = $e->getTarget(); $result['response'] = $e->getResponse(); }, 10000); $mockResponse = $this->getMockForAbstractClass('Zend\\Stdlib\\ResponseInterface'); $mockMvcEvent = $this->getMock('Zend\\Mvc\\MvcEvent', $methods = array('getResponse')); $mockMvcEvent->expects($this->any())->method('getResponse')->will($this->returnValue($mockResponse)); $listener->sendResponse($mockMvcEvent); $expected = array('target' => $listener, 'response' => $mockResponse); $this->assertEquals($expected, $result); }
/** * @param ContainerInterface $container * @return SendResponseListener */ public function __invoke(ContainerInterface $container) { $listener = new SendResponseListener(); $listener->setEventManager($container->get('EventManager')); return $listener; }