public function setUp() { StaticEventManager::resetInstance(); $mockSharedEventManager = $this->getMock('Zend\\EventManager\\SharedEventManagerInterface'); $mockSharedEventManager->expects($this->any())->method('getListeners')->will($this->returnValue(array())); $mockEventManager = $this->getMock('Zend\\EventManager\\EventManagerInterface'); $mockEventManager->expects($this->any())->method('getSharedManager')->will($this->returnValue($mockSharedEventManager)); $mockApplication = $this->getMock('Zend\\Mvc\\ApplicationInterface'); $mockApplication->expects($this->any())->method('getEventManager')->will($this->returnValue($mockEventManager)); $event = new MvcEvent(); $event->setApplication($mockApplication); $event->setRequest(new Request()); $event->setResponse(new Response()); $routeMatch = new RouteMatch(array('action' => 'test')); $routeMatch->setMatchedRouteName('some-route'); $event->setRouteMatch($routeMatch); $services = new Locator(); $plugins = $this->plugins = new PluginManager(); $plugins->setServiceLocator($services); $controllers = $this->controllers = new ControllerManager(); $controllers->setFactory('forward', function () use($plugins) { $controller = new ForwardController(); $controller->setPluginManager($plugins); return $controller; }); $controllers->setInvokableClass('ZendTest\\Mvc\\Controller\\TestAsset\\ForwardFq', 'ZendTest\\Mvc\\Controller\\TestAsset\\ForwardFqController'); $controllers->setServiceLocator($services); $controllerLoader = function () use($controllers) { return $controllers; }; $services->add('ControllerLoader', $controllerLoader); $services->add('ControllerManager', $controllerLoader); $services->add('ControllerPluginManager', function () use($plugins) { return $plugins; }); $services->add('Zend\\ServiceManager\\ServiceLocatorInterface', function () use($services) { return $services; }); $services->add('EventManager', function () use($mockEventManager) { return $mockEventManager; }); $services->add('SharedEventManager', function () use($mockSharedEventManager) { return $mockSharedEventManager; }); $this->controller = new SampleController(); $this->controller->setEvent($event); $this->controller->setServiceLocator($services); $this->controller->setPluginManager($plugins); $this->plugin = $this->controller->plugin('forward'); }