public function RouteTest::testPath

File

drupal/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteTest.php, line 36

Class

RouteTest

Namespace

Symfony\Component\Routing\Tests

Code

public function testPath() {
  $route = new Route('/{foo}');
  $route
    ->setPath('/{bar}');
  $this
    ->assertEquals('/{bar}', $route
    ->getPath(), '->setPath() sets the path');
  $route
    ->setPath('');
  $this
    ->assertEquals('/', $route
    ->getPath(), '->setPath() adds a / at the beginning of the path if needed');
  $route
    ->setPath('bar');
  $this
    ->assertEquals('/bar', $route
    ->getPath(), '->setPath() adds a / at the beginning of the path if needed');
  $this
    ->assertEquals($route, $route
    ->setPath(''), '->setPath() implements a fluent interface');
  $route
    ->setPath('//path');
  $this
    ->assertEquals('/path', $route
    ->getPath(), '->setPath() does not allow two slahes "//" at the beginning of the path as it would be confused with a network path when generating the path from the route');
}