Example #1
0
 /**
  * Route should set name and be cached by Router
  */
 public function testRouteSetsNameAndIsCached()
 {
     $router = new RouterMock();
     $route = new Route('/foo/bar', function () {
     });
     $route->setRouter($router);
     $route->name('foo');
     $cacheKeys = array_keys($router->cache);
     $cacheValues = array_values($router->cache);
     $this->assertEquals($cacheKeys[0], 'foo');
     $this->assertSame($cacheValues[0], $route);
 }
Example #2
0
 /**
  * Map a route to a callback function
  *
  * @param string $pattern The URL pattern (ie. "/books/:id")
  * @param mixed $callable Anything that returns TRUE for is_callable()
  * @param string $method The HTTP request method (GET, POST, PUT, DELETE)
  * @return Route
  */
 public function map($pattern, $callable, $method)
 {
     $route = new Route($pattern, $callable);
     $route->setRouter($this);
     $this->routes[$method][] = $route;
     return $route;
 }