public function UrlGeneratorTest::testGenerateRelativePath in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/symfony/routing/Tests/Generator/UrlGeneratorTest.php \Symfony\Component\Routing\Tests\Generator\UrlGeneratorTest::testGenerateRelativePath()
File
- vendor/
symfony/ routing/ Tests/ Generator/ UrlGeneratorTest.php, line 498
Class
Namespace
Symfony\Component\Routing\Tests\GeneratorCode
public function testGenerateRelativePath() {
$routes = new RouteCollection();
$routes
->add('article', new Route('/{author}/{article}/'));
$routes
->add('comments', new Route('/{author}/{article}/comments'));
$routes
->add('host', new Route('/{article}', array(), array(), array(), '{author}.example.com'));
$routes
->add('scheme', new Route('/{author}/blog', array(), array(), array(), '', array(
'https',
)));
$routes
->add('unrelated', new Route('/about'));
$generator = $this
->getGenerator($routes, array(
'host' => 'example.com',
'pathInfo' => '/fabien/symfony-is-great/',
));
$this
->assertSame('comments', $generator
->generate('comments', array(
'author' => 'fabien',
'article' => 'symfony-is-great',
), UrlGeneratorInterface::RELATIVE_PATH));
$this
->assertSame('comments?page=2', $generator
->generate('comments', array(
'author' => 'fabien',
'article' => 'symfony-is-great',
'page' => 2,
), UrlGeneratorInterface::RELATIVE_PATH));
$this
->assertSame('../twig-is-great/', $generator
->generate('article', array(
'author' => 'fabien',
'article' => 'twig-is-great',
), UrlGeneratorInterface::RELATIVE_PATH));
$this
->assertSame('../../bernhard/forms-are-great/', $generator
->generate('article', array(
'author' => 'bernhard',
'article' => 'forms-are-great',
), UrlGeneratorInterface::RELATIVE_PATH));
$this
->assertSame('//bernhard.example.com/app.php/forms-are-great', $generator
->generate('host', array(
'author' => 'bernhard',
'article' => 'forms-are-great',
), UrlGeneratorInterface::RELATIVE_PATH));
$this
->assertSame('https://example.com/app.php/bernhard/blog', $generator
->generate('scheme', array(
'author' => 'bernhard',
), UrlGeneratorInterface::RELATIVE_PATH));
$this
->assertSame('../../about', $generator
->generate('unrelated', array(), UrlGeneratorInterface::RELATIVE_PATH));
}