Esempio n. 1
0
 /**
  * @test
  */
 public function methodSetByConstructorGetsReturnedInCapitalLetters()
 {
     $route = new Route('get');
     $this->assertSame(['GET'], $route->getMethods());
     $route = Route::create('get', '/', 'test');
     $this->assertSame(['GET'], $route->getMethods());
 }
Esempio n. 2
0
 /**
  * Validates given route for configuration correctness and throws \ConfigurationException
  * if any required configuration is missing. Returns true if everything's fine
  *
  * @param Route $route
  * @throws \ConfigurationException
  */
 protected function validateRoute(Route $route)
 {
     if (null === $route->getPath()) {
         throw new \ConfigurationException('Route must have defined a path');
     }
     if (null === $route->getTarget()) {
         throw new \ConfigurationException('Route must have defined a target');
     }
     if (0 === count($route->getMethods())) {
         throw new \ConfigurationException('Route must at least accept one request method');
     }
     if (!is_string($route->getTarget()) and null === $route->getName()) {
         throw new \ConfigurationException('If defined route target is not a string a name has to be set');
     }
 }