/**
  * Create a RoutePathCompilationException from a route
  * and an optional previous exception
  *
  * @param Route $route The route that failed to compile
  * @param Exception $previous The previous exception
  * @return RoutePathCompilationException
  */
 public static function createFromRoute(Route $route, Exception $previous = null)
 {
     $error = null !== $previous ? $previous->getMessage() : null;
     $code = null !== $previous ? $previous->getCode() : null;
     $message = sprintf(static::MESSAGE_FORMAT, $route->getPath());
     $message .= ' ' . sprintf(static::FAILURE_MESSAGE_TITLE_FORMAT, $error);
     $exception = new static($message, $code, $previous);
     $exception->setRoute($route);
     return $exception;
 }
Exemple #2
0
 public function testPathGetSet()
 {
     // Test data
     $test_callable = $this->getTestCallable();
     $test_path = '/this-is-a-path';
     // Empty constructor
     $route = new Route($test_callable);
     $this->assertNotNull($route->getPath());
     $this->assertInternalType('string', $route->getPath());
     // Set in constructor
     $route = new Route($test_callable, $test_path);
     $this->assertSame($test_path, $route->getPath());
     // Set in method
     $route = new Route($test_callable);
     $route->setPath($test_path);
     $this->assertSame($test_path, $route->getPath());
 }