$this->Stop();
}
+ /*!
+ Sets the response code to HTTP 302 FOUND and redirects the page to a new
+ location.
+ @param string The destination location of the redirect.
+ */
+ public function StopWithRedirect($location)
+ {
+ $this->response->headers['Location'] = $location;
+ $this->StopWithCode(ResponseCode::FOUND);
+ }
+
+
/*!
Wrapper around PHP exit().
*/
$mock = $this->ConfigureMock(array('Stop'), $globals);
$mock->request()->url = 'another/action';
-
+
$mock->expects($this->once())
->method('Stop');
$mock->Stop();
}
+ public function testStopWithRedirect()
+ {
+ $globals = array();
+ $mock = $this->ConfigureMock(array('_Exit'), $globals);
+ $mock->expects($this->once())
+ ->method('_Exit');
+
+ $output_filter = $this->getMock('hoplite\http\OutputFilter', array(), array($mock));
+ $output_filter->expects($this->once())
+ ->method('FilterOutput')
+ ->with($this->isInstanceOf('hoplite\http\Request'),
+ $this->isInstanceOf('hoplite\http\Response'));
+
+ $mock->set_output_filter($output_filter);
+
+ $mock->StopWithRedirect('/foo/bar');
+
+ $this->assertEquals('/foo/bar', $mock->response()->headers['Location']);
+ $this->assertEquals(http\ResponseCode::FOUND, $mock->response()->response_code);
+ }
+
public function testAbsolutify()
{
$globals = array(