/** * @test */ public function parseSetsDefaultValueOfRoutePartsRecursively() { $this->route->setUriPattern('{foo.bar}'); $this->route->setRoutePartsConfiguration(array('foo.bar' => array('handler' => 'SomeRoutePartHandler'))); $this->route->setDefaults(array('foo' => array('bar' => 'SomeDefaultValue'))); $mockRoutePartHandler = $this->getMock(\TYPO3\Flow\Mvc\Routing\DynamicRoutePartInterface::class); $mockRoutePartHandler->expects($this->once())->method('setDefaultValue')->with('SomeDefaultValue'); $this->mockObjectManager->expects($this->once())->method('get')->with('SomeRoutePartHandler')->will($this->returnValue($mockRoutePartHandler)); $this->route->parse(); }
/** * Creates \TYPO3\Flow\Mvc\Routing\Route objects from the injected routes * configuration. * * @return void * @throws InvalidRouteSetupException */ protected function createRoutesFromConfiguration() { if ($this->routesCreated === FALSE) { $this->routes = array(); $routesWithHttpMethodConstraints = array(); foreach ($this->routesConfiguration as $routeConfiguration) { $route = new Route(); if (isset($routeConfiguration['name'])) { $route->setName($routeConfiguration['name']); } $uriPattern = $routeConfiguration['uriPattern']; $route->setUriPattern($uriPattern); if (isset($routeConfiguration['defaults'])) { $route->setDefaults($routeConfiguration['defaults']); } if (isset($routeConfiguration['routeParts'])) { $route->setRoutePartsConfiguration($routeConfiguration['routeParts']); } if (isset($routeConfiguration['toLowerCase'])) { $route->setLowerCase($routeConfiguration['toLowerCase']); } if (isset($routeConfiguration['appendExceedingArguments'])) { $route->setAppendExceedingArguments($routeConfiguration['appendExceedingArguments']); } if (isset($routeConfiguration['httpMethods'])) { if (isset($routesWithHttpMethodConstraints[$uriPattern]) && $routesWithHttpMethodConstraints[$uriPattern] === FALSE) { throw new InvalidRouteSetupException(sprintf('There are multiple routes with the uriPattern "%s" and "httpMethods" option set. Please specify accepted HTTP methods for all of these, or adjust the uriPattern', $uriPattern), 1365678427); } $routesWithHttpMethodConstraints[$uriPattern] = TRUE; $route->setHttpMethods($routeConfiguration['httpMethods']); } else { if (isset($routesWithHttpMethodConstraints[$uriPattern]) && $routesWithHttpMethodConstraints[$uriPattern] === TRUE) { throw new InvalidRouteSetupException(sprintf('There are multiple routes with the uriPattern "%s" and "httpMethods" option set. Please specify accepted HTTP methods for all of these, or adjust the uriPattern', $uriPattern), 1365678432); } $routesWithHttpMethodConstraints[$uriPattern] = FALSE; } $this->routes[] = $route; } $this->routesCreated = TRUE; } }