/** * @covers \BjyAuthorize\View\RedirectionStrategy::onDispatchError * @covers \BjyAuthorize\View\RedirectionStrategy::setRedirectRoute * @covers \BjyAuthorize\View\RedirectionStrategy::setRedirectUri */ public function testWillRedirectToRouteOnSetRoute() { $this->strategy->setRedirectRoute('redirect/route'); $this->strategy->setRedirectUri(null); $mvcEvent = $this->getMock('Zend\\Mvc\\MvcEvent'); $response = $this->getMock('Zend\\Http\\Response'); $routeMatch = $this->getMock('Zend\\Mvc\\Router\\RouteMatch', array(), array(), '', false); $route = $this->getMock('Zend\\Mvc\\Router\\RouteInterface'); $headers = $this->getMock('Zend\\Http\\Headers'); $mvcEvent->expects($this->any())->method('getResponse')->will($this->returnValue($response)); $mvcEvent->expects($this->any())->method('getRouteMatch')->will($this->returnValue($routeMatch)); $mvcEvent->expects($this->any())->method('getRouter')->will($this->returnValue($route)); $mvcEvent->expects($this->any())->method('getError')->will($this->returnValue(Route::ERROR)); $response->expects($this->any())->method('getHeaders')->will($this->returnValue($headers)); $response->expects($this->once())->method('setStatusCode')->with(302); $headers->expects($this->once())->method('addHeaderLine')->with('Location', 'http://www.example.org/'); $route->expects($this->any())->method('assemble')->with(array(), array('name' => 'redirect/route'))->will($this->returnValue('http://www.example.org/')); $mvcEvent->expects($this->once())->method('setResponse')->with($response); $this->strategy->onDispatchError($mvcEvent); }