From c3c6f689099937e6e4ecf25b7fe8c780df1500f9 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Tue, 25 Oct 2016 12:27:20 -0700 Subject: [PATCH] Removed another case of $route passing. Updated tests. --- VERSION | 2 +- flight/net/Route.php | 3 --- tests/RouterTest.php | 17 +++++++++++++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/VERSION b/VERSION index 6261a05..d5e98f7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.3.1 \ No newline at end of file +1.3.2 \ No newline at end of file diff --git a/flight/net/Route.php b/flight/net/Route.php index 2efdd00..a3c4457 100644 --- a/flight/net/Route.php +++ b/flight/net/Route.php @@ -74,9 +74,6 @@ class Route { public function matchUrl($url, $case_sensitive = false) { // Wildcard or exact match if ($this->pattern === '*' || $this->pattern === $url) { - if ($this->pass) { - $this->params[] = $this; - } return true; } diff --git a/tests/RouterTest.php b/tests/RouterTest.php index dedc0ad..a99ce25 100644 --- a/tests/RouterTest.php +++ b/tests/RouterTest.php @@ -181,6 +181,12 @@ class RouterTest extends PHPUnit_Framework_TestCase function testRouteObjectPassing(){ $this->router->map('/yes_route', function($route){ $this->assertTrue(is_object($route)); + $this->assertTrue(is_array($route->methods)); + $this->assertTrue(is_array($route->params)); + $this->assertEquals(sizeof($route->params), 0); + $this->assertEquals($route->regex, null); + $this->assertEquals($route->splat, ''); + $this->assertTrue($route->pass); }, true); $this->request->url = '/yes_route'; @@ -194,6 +200,17 @@ class RouterTest extends PHPUnit_Framework_TestCase $this->check(); } + function testRouteWithParameters() { + $this->router->map('/@one/@two', function($one, $two, $route){ + $this->assertEquals(sizeof($route->params), 2); + $this->assertEquals($route->params['one'], $one); + $this->assertEquals($route->params['two'], $two); + }, true); + $this->request->url = '/1/2'; + + $this->check(); + } + // Test splat function testSplatWildcard(){ $this->router->map('/account/*', function($route){