Exemple #1
0
 /**
  * Returns a http route fixture.
  * @param array $rules
  * @param array $defaultValues
  * @return \Brickoo\Component\Routing\Route\HttpRoute
  */
 private function getHttpRouteFixture(array $rules = [], array $defaultValues = [])
 {
     $route = new HttpRoute("test.route", "/article/{name}/{page}", "NewspaperController", "getArticle");
     $route->setRules($rules);
     $route->setDefaultValues($defaultValues);
     return $route;
 }
 /**
  * @covers Brickoo\Component\Routing\Route\Matcher\HttpRouteMatcher::getRouteParameters
  * @covers Brickoo\Component\Routing\Route\Matcher\CommonRouteMatcherStructure::collectRouteParameters
  * @covers Brickoo\Component\Routing\Route\Matcher\CommonRouteMatcherStructure::getRuleCorrespondingRouteParameter
  */
 public function testGetRouteParametersWithPageAsDefaultValue()
 {
     $expectedParameters = ["name" => "doing-unit-tests", "page" => 1];
     $routeHttpMatcher = new HttpRouteMatcher($this->getRequestFixture("/doing-unit-tests"), new RoutePathRegexGenerator());
     $route = new HttpRoute("test.route", "/{name}/{page}", "ControllerPath");
     $route->setRules(["name" => "[\\w\\-]+", "page" => "[0-9]+"]);
     $route->setDefaultValues(["page" => 1]);
     $this->assertTrue($routeHttpMatcher->matchesRoute($route));
     $this->assertEquals($expectedParameters, $routeHttpMatcher->getRouteParameters());
 }