public function testMatchesOptionalParameters() { $pattern = '/archive/:year(/:month(/:day))'; $route1 = new \Slim\Route($pattern, function () { }); $this->assertTrue($route1->matches('/archive/2010')); $this->assertEquals(array('year' => '2010'), $route1->getParams()); $route2 = new \Slim\Route($pattern, function () { }); $this->assertTrue($route2->matches('/archive/2010/05')); $this->assertEquals(array('year' => '2010', 'month' => '05'), $route2->getParams()); $route3 = new \Slim\Route($pattern, function () { }); $this->assertTrue($route3->matches('/archive/2010/05/13')); $this->assertEquals(array('year' => '2010', 'month' => '05', 'day' => '13'), $route3->getParams()); }
/** * Route does not match URI with wildcard */ public function testRouteDoesNotMatchResourceWithWildcard() { $resource = '/hello'; $route = new \Slim\Route('/hello/:path+', function () { }); $result = $route->matches($resource); $this->assertFalse($result); $this->assertEquals(array(), $route->getParams()); }