public function testMatchReturnsMatchedRouteName()
 {
     $routeName = 'some-route';
     $routeMatch = $this->createRouteMatch($routeName);
     /** @var RouteStackInterface|PHPUnit_Framework_MockObject_MockObject $router */
     $router = $this->getMockBuilder(RouteStackInterface::class)->disableOriginalConstructor()->getMock();
     $router->expects($this->any())->method('match')->will($this->returnValue($routeMatch));
     $routeMatcher = new RouteMatcher($router);
     $this->assertEquals($routeName, $routeMatcher->match('GET', '/some/url'));
 }
 /**
  * @return JsonModel
  */
 public function matchRouteAction()
 {
     $data = $this->params()->fromQuery();
     $route = null;
     if (isset($data['method']) && !empty($data['method']) && isset($data['url']) && !empty($data['url'])) {
         if (null !== ($routeName = $this->routeMatcher->match($data['method'], $data['url']))) {
             $route = $this->routeCollection->getRoute($routeName);
             $route = ['name' => $route->getName(), 'url' => $route->getUrl(), 'controller' => $route->getController(), 'action' => $route->getAction()];
         }
     }
     return new JsonModel(['requestedRouteData' => $data, 'routeMatch' => $route]);
 }
 public function matchAction()
 {
     /** @var Request $request */
     $request = $this->getRequest();
     $method = strtoupper($request->getParam('method'));
     $url = $request->getParam('url');
     $match = $this->routeMatcher->match($method, $url);
     if (null !== $match) {
         $route = $this->routeCollection->getRoute($match);
         $this->console->writeLine(sprintf('A match was found for %s "%s"', $method, $url), ColorInterface::GREEN);
         $this->console->write('        Name:  ');
         $this->console->writeLine($route->getName(), ColorInterface::LIGHT_WHITE);
         $this->console->write('         URL:  ');
         $this->console->writeLine($route->getUrl(), ColorInterface::LIGHT_WHITE);
         $this->console->write('  Controller:  ');
         $this->console->writeLine($route->getController(), ColorInterface::LIGHT_WHITE);
         $this->console->write('      Action:  ');
         $this->console->writeLine($route->getAction(), ColorInterface::LIGHT_WHITE);
     } else {
         $this->console->writeLine(sprintf('No match found for %s "%s"', $method, $url), ColorInterface::RED);
     }
 }