Skip to content

Commit

Permalink
Quick-clean way of fixing #18
Browse files Browse the repository at this point in the history
  • Loading branch information
Augusto Pascutti committed Mar 11, 2012
1 parent 4c2595c commit 9e37e30
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions library/Respect/Rest/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ public function dispatchRequest(Request $request=null)
if ($this->matchRoute($request, $route, $params))
return $this->configureRequest($request, $route, static::cleanUpParams($params));

header('HTTP/1.1 404');
$request->route = null;
return $request;
}
Expand Down
20 changes: 20 additions & 0 deletions tests/library/Respect/Rest/RouterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,24 @@ function test_converting_router_to_string_should_dispatch_and_run_it()
$response = (string) $this->router;
$this->assertEquals('ok', $response);
}
function test_dispatch_non_existing_route()
{
global $header;
$this->router->any('/', function() {});
$this->router->dispatch('get', '/my/name/is/hall');
$this->assertContains('HTTP/1.1 404', $header);
}
}
$header=array();
/**
* [header description]
* @return void
*/
function header($string, $replace=true, $http_response_code=200)
{
global $header;
if (!$replace && isset($header))
return;

$header[$string] = $string;
}

0 comments on commit 9e37e30

Please sign in to comment.