Permalink
Browse files

Removed another case of $route passing. Updated tests.

1 parent 6aea739 commit c3c6f689099937e6e4ecf25b7fe8c780df1500f9 @mikecao committed Oct 25, 2016
Showing with 18 additions and 4 deletions.
  1. +1 −1 VERSION
  2. +0 −3 flight/net/Route.php
  3. +17 −0 tests/RouterTest.php
View
@@ -1 +1 @@
-1.3.1
+1.3.2
@@ -74,9 +74,6 @@ public function __construct($pattern, $callback, $methods, $pass) {
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;
}
View
@@ -181,6 +181,12 @@ function testWildcard(){
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 @@ function testRouteObjectPassing(){
$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){

0 comments on commit c3c6f68

Please sign in to comment.