Example #1
0
 private function checkGeneratedResources($methodArray, $namedArray)
 {
     /** @var Route $route */
     foreach ($this->container as $route) {
         $path = $route->getParsed()->getPath();
         $methods = $methodArray[$path];
         $methodKey = array_search($route->getMethod(), $methods, true);
         unset($methodArray[$path][$methodKey]);
         if (empty($methodArray[$path])) {
             unset($methodArray[$path]);
         }
     }
     if (!empty($methodArray)) {
         $this->fail("Some routes have not been generated");
     }
     foreach ($namedArray as $name => $path) {
         $route = $this->container->get($name);
         $this->assertEquals($path, $route->getParsed()->getPath());
     }
 }
Example #2
0
 public function __destruct()
 {
     $this->container->add($this->route);
 }
Example #3
0
 public function testSameDynamicPathsWithDifferentMethodIsMatched()
 {
     $routeA = new Route('GET', new RouteData('path/{a}', ['a' => '([^/]+)']));
     $routeB = new Route('PUT', new RouteData('path/{a}', ['a' => '([^/]+)']));
     $routes = new RouteContainer();
     $routes->add($routeA);
     $routes->add($routeB);
     $matcher = new RouteMatcher($routes, new Configuration());
     $match = $matcher->match(new Request(Request::METHOD_GET, 'path/a'));
     $this->assertSame($routeA, $match->getRoute());
     $match = $matcher->match(new Request(Request::METHOD_PUT, 'path/a'));
     $this->assertSame($routeB, $match->getRoute());
 }