public function setUp() { Console::overrideIsConsole(false); parent::setUp(); $this->request = new Request(); $this->request->setHeaders(new Headers()); $this->routeMatch = new RouteMatch(array('controller' => $this->controllerName)); $this->event = $this->getApplication()->getMvcEvent(); $this->event->setRequest($this->request); $this->event->setRouteMatch($this->routeMatch); $this->event->getRouter()->setRequestUri(new HttpUri('http://localhost')); if (null === $this->controller) { if (null === $this->controllerName) { throw new PHPUnit_Framework_Exception('No controller name was specified in the test'); } $this->controller = $this->getServiceManager()->get('ControllerLoader')->get($this->controllerName); } $this->controller->setEvent($this->event); }