Skip to content

Commit

Permalink
Merge branch 'master' of github.com:letsdrink/ouzo
Browse files Browse the repository at this point in the history
  • Loading branch information
bbankowski committed Sep 26, 2013
2 parents 6c9050e + 0a86167 commit e92c994
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/Ouzo/Routing/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Route
*/
public static $routes = array();
public static $methods = array('GET', 'POST', 'PUT', 'PATCH', 'DELETE');
public static $validate = true;


public static function get($uri, $action)
Expand Down Expand Up @@ -82,7 +83,7 @@ private static function _createRouteAction($controller, $action)

private static function _addRoute($method, $uri, $action, $requireAction = true, $except = array())
{
if (self::_existRouteRule($method, $uri)) {
if (self::$validate && self::_existRouteRule($method, $uri)) {
$methods = is_array($method) ? implode(', ', $method) : $method;
throw new InvalidArgumentException('Route rule for method ' . $methods . ' and URI "' . $uri . '" already exists');
}
Expand Down
1 change: 1 addition & 0 deletions lib/Ouzo/Tests/ControllerTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ private function _initFrontController()
public function post($url, $data)
{
$_SERVER['REQUEST_URI'] = $this->_prefixSystem . $url;
$_SERVER['REQUEST_METHOD'] = 'POST';
$_POST = $data;
$_GET = $this->_parseUrlParams($_SERVER['REQUEST_URI']);

Expand Down
18 changes: 18 additions & 0 deletions test/lib/Ouzo/Routing/RouteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,22 @@ public function shouldRouteForAllowingAllActionsInController()
$this->assertEquals('users', $routes[0]->getController());
$this->assertNull($routes[0]->getAction());
}

/**
* @test
*/
public function shouldNotValidateExistingRoutes()
{
//given
Route::$validate = false;
Route::get('/users/index', 'users#index');
Route::get('/users/index', 'users#index');
Route::$validate = true;

//when
$routes = Route::getRoutes();

//then
Assert::thatArray($routes)->hasSize(2);
}
}

0 comments on commit e92c994

Please sign in to comment.