$this->request->http_method = $this->request->data['_SERVER']['REQUEST_METHOD'];
// Dispatch the request to an Action.
- $this->RouteRequest($url);
+ $this->RouteRequest($this->request);
// When control returns here, all actions have been invoked and it's time
// to start the output filter and exit.
/*!
Invoked by Run() and can be invoked by others to evaluate and perform the
lookup in the UrlMap. This then calls InvokeAction().
- @param string The URL fragment to look up in the
+ @param Request The Request whose URL will be routed
*/
- public function RouteRequest($url_fragment)
+ public function RouteRequest(Request $request)
{
- $url_map_value = $this->url_map->Evaluate($url_fragment);
+ $url_map_value = $this->url_map->Evaluate($request);
$action = NULL;
if ($url_map_value)
));
$mock = $this->ConfigureMock(array('RouteRequest', 'Stop'), $globals);
+ $mock->request()->url = 'some/action/42';
+
$mock->expects($this->once())
->method('RouteRequest')
- ->with($this->equalTo('some/action/42'));
+ ->with($this->equalTo($mock->request()));
$mock->expects($this->once())
->method('Stop');
$globals = array();
$mock = $this->ConfigureMock(array('Stop', 'InvokeAction'), $globals);
- $fragment = 'some/action/42';
+ $mock->request()->url = 'some/action/42';
$map_value = 'ActionReporter';
$action = new ActionReporter($mock);
$url_map = $this->getMock('hoplite\http\UrlMap', array(), array($mock));
$url_map->expects($this->once())
->method('Evaluate')
- ->with($this->equalTo($fragment))
+ ->with($this->equalTo($mock->request()))
->will($this->returnValue($map_value));
$url_map->expects($this->once())
->method('LookupAction')
->will($this->returnValue($action));
$mock->set_url_map($url_map);
- $mock->RouteRequest($fragment);
+ $mock->RouteRequest($mock->request());
}
public function testRouteRequestInvalid()
$globals = array();
$mock = $this->ConfigureMock(array('Stop'), $globals);
- $fragment = 'another/action';
+ $mock->request()->url = 'another/action';
$mock->expects($this->once())
->method('Stop');
$url_map = $this->getMock('hoplite\http\UrlMap', array(), array($mock));
$url_map->expects($this->once())
->method('Evaluate')
- ->with($this->equalTo($fragment));
+ ->with($this->equalTo($mock->request()));
$mock->set_url_map($url_map);
- $mock->RouteRequest($fragment);
+ $mock->RouteRequest($mock->request());
$this->assertEquals(http\ResponseCode::NOT_FOUND, $mock->response()->response_code);
}