/**
  * {@inheritdoc}
  */
 public function match(Request $request)
 {
     $this->router->handle($request->getUri()->getPath());
     if (!$this->router->wasMatched()) {
         // TODO Is it worth to validate, if route matches but the method is incompatible?
         return RouteResult::fromRouteFailure();
     }
     $matchedRoute = $this->router->getMatchedRoute();
     return RouteResult::fromRouteMatch($matchedRoute->getName(), $this->router->getNamespaceName(), $this->collectParams($matchedRoute));
 }
 /**
  * @dataProvider routesProvider
  *
  * @param $arRoute
  * @param $strUri
  * @param $strClassName
  */
 public function testRoutes($arRoute, $strUri, $strClassName)
 {
     $this->router->add($arRoute['route'], $arRoute['parameters'])->setName($arRoute['name']);
     $this->router->handle($strUri);
     $boolMatched = $this->router->wasMatched();
     $this->assertTrue($boolMatched, 'failed to match ' . $strUri);
     $strRouteName = $this->router->getMatchedRoute()->getName();
     $this->assertEquals($arRoute['name'], $strRouteName, 'matched wrong route');
     $this->setUpDispatcher();
     $this->dispatcher->dispatch();
     $strControllerClassName = $this->dispatcher->getControllerClass();
     $this->assertEquals($strClassName, $strControllerClassName, 'wrong controller class name');
 }
 /**
  * @group excluded
  * @dataProvider easyMismatchedProvider
  *
  * @param $strUri
  */
 public function testEasyMismatched($strUri)
 {
     $this->router->handle($strUri);
     $boolMatched = $this->router->wasMatched();
     $this->assertFalse($boolMatched, 'matched when should not');
 }
Example #4
0
 public function wasMatched()
 {
     return parent::wasMatched();
 }