Exemplo n.º 1
0
 /**
  * Builds an uri string based on the parameters provided.
  * @param string $routeName the route to use for the build
  * @param array $pathParameters the path parameters as key/value pairs
  * @param string $queryString
  * @throws \Brickoo\Component\Routing\Route\Exception\PathNotValidException
  * @internal param string $queryParameters the query parameters
  * @return string the built uri
  */
 public function build($routeName, array $pathParameters = [], $queryString = "")
 {
     Assert::isString($routeName);
     Assert::isString($queryString);
     $route = $this->router->getRoute($routeName);
     $expectedPath = $this->getExpectedRoutePath($route, $pathParameters);
     $matches = [];
     if (preg_match_all($this->regexGenerator->generate($route), $expectedPath, $matches) === 0) {
         throw new PathNotValidException($routeName, $expectedPath);
     }
     return $this->createUriString($expectedPath, $queryString);
 }
Exemplo n.º 2
0
 /**
  * @covers Brickoo\Component\Routing\Router::getRequestRoute
  * @covers Brickoo\Component\Routing\Router::getMatchingRoute
  * @covers Brickoo\Component\Routing\Router::getMatchingRequestRouteFromCollection
  * @covers Brickoo\Component\Routing\Exception\NoMatchingRouteFoundException
  * @expectedException \Brickoo\Component\Routing\Exception\NoMatchingRouteFoundException
  */
 public function testTryingToGetNotAvailableRequestMAtchingThrowsException()
 {
     $router = new Router(new CallbackRouteCollector(function () {
     }), new BasicRouteMatcher("/", new RoutePathRegexGenerator()));
     $router->getRequestRoute();
 }