Removed another case of $route passing. Updated tests.

pull/301/head v1.3.2
Mike Cao 8 years ago
parent 6aea7394c4
commit c3c6f68909

@ -1 +1 @@
1.3.1
1.3.2

@ -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;
}

@ -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){

Loading…
Cancel
Save