Beispiel #1
0
 public function testDynamicFilterMatch()
 {
     $collection = new RouteCollection();
     $route1 = new Route('/hello/{name}', ['_controller' => 'TastRouter\\Test\\controllers\\FooController::indexAction', 'methods' => 'GET', 'name' => '\\w+']);
     $route2 = new Route('/foo1/{foo1}/foo2/{foo2}', ['_controller' => 'TastRouter\\Test\\controllers\\FooController::indexAction', 'methods' => 'GET', 'foo1' => '\\w+', 'foo2' => '\\d+']);
     //        $collection->attachRoute($route1);
     $collection->attachRoute($route2);
     $router = new Router($collection);
     //        $route = $router->match('/hello/xujiajun','GET');
     //        $this->assertEquals($route->getParameterByName('name'),'xujiajun');
     $router->match('/foo1/foo1/foo2/123', 'GET');
     $this->assertEquals($route2->getParameterByName('foo1'), 'foo1');
     $this->assertEquals($route2->getParameterByName('foo2'), '123');
     //        $router->match('/foo1/foo1/foo2/fo2','GET');
 }
Beispiel #2
0
 /**
  * @expectedException     Exception
  */
 public function testFailGenerate()
 {
     list($route1, $route2, $route3, $route4) = $this->getRoutes();
     $collection = new RouteCollection();
     $collection->attachRoute($route2);
     $router = new Router($collection);
     $router->match("/foo1/xujiajun", 'GET');
     $url = $router->generate('say_hello', ['xujiajun']);
     $this->assertEquals($url, '/hello/xujiajun');
 }