/**
  * @test
  */
 public function routeMatchesIfRequestMethodIsAccepted()
 {
     $this->route->setUriPattern('');
     $this->route->setHttpMethods(array('POST', 'PUT'));
     $mockHttpRequest = $this->getMockBuilder('TYPO3\\Flow\\Http\\Request')->disableOriginalConstructor()->getMock();
     $mockUri = $this->getMockBuilder('TYPO3\\Flow\\Http\\Uri')->disableOriginalConstructor()->getMock();
     $mockUri->expects($this->any())->method('getPath')->will($this->returnValue('/'));
     $mockHttpRequest->expects($this->any())->method('getUri')->will($this->returnValue($mockUri));
     $mockBaseUri = $this->getMockBuilder('TYPO3\\Flow\\Http\\Uri')->disableOriginalConstructor()->getMock();
     $mockBaseUri->expects($this->any())->method('getPath')->will($this->returnValue('/'));
     $mockHttpRequest->expects($this->any())->method('getBaseUri')->will($this->returnValue($mockBaseUri));
     $mockHttpRequest->expects($this->atLeastOnce())->method('getMethod')->will($this->returnValue('PUT'));
     $this->assertTrue($this->route->matches($mockHttpRequest), 'Route should match PUT requests if POST and PUT requests are accepted.');
 }
 /**
  * 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;
     }
 }
 /**
  * Adds a route that can be used in the functional tests
  *
  * @param string $name Name of the route
  * @param string $uriPattern The uriPattern property of the route
  * @param array $defaults An array of defaults declarations
  * @param boolean $appendExceedingArguments If exceeding arguments may be appended
  * @param array $httpMethods An array of accepted http methods
  * @return void
  * @api
  */
 protected function registerRoute($name, $uriPattern, array $defaults, $appendExceedingArguments = false, array $httpMethods = null)
 {
     $route = new Route();
     $route->setName($name);
     $route->setUriPattern($uriPattern);
     $route->setDefaults($defaults);
     $route->setAppendExceedingArguments($appendExceedingArguments);
     if ($httpMethods !== null) {
         $route->setHttpMethods($httpMethods);
     }
     $this->router->addRoute($route);
 }