/** * @covers \BjyAuthorize\View\RedirectionStrategy::onDispatchError * @covers \BjyAuthorize\View\RedirectionStrategy::setRedirectUri */ public function testWillRedirectToRouteOnSetUriWithApplicationError() { $this->strategy->setRedirectUri('http://www.example.org/'); $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'); $exception = $this->getMock('BjyAuthorize\\Exception\\UnauthorizedException'); $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(Application::ERROR_EXCEPTION)); $mvcEvent->expects($this->any())->method('getParam')->with('exception')->will($this->returnValue($exception)); $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/'); $mvcEvent->expects($this->once())->method('setResponse')->with($response); $this->strategy->onDispatchError($mvcEvent); }