You are here

public function UrlGeneratorTest::testGenerateNetworkPath in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/routing/Tests/Generator/UrlGeneratorTest.php \Symfony\Component\Routing\Tests\Generator\UrlGeneratorTest::testGenerateNetworkPath()

File

vendor/symfony/routing/Tests/Generator/UrlGeneratorTest.php, line 480

Class

UrlGeneratorTest

Namespace

Symfony\Component\Routing\Tests\Generator

Code

public function testGenerateNetworkPath() {
  $routes = $this
    ->getRoutes('test', new Route('/{name}', array(), array(), array(), '{locale}.example.com', array(
    'http',
  )));
  $this
    ->assertSame('//fr.example.com/app.php/Fabien', $this
    ->getGenerator($routes)
    ->generate('test', array(
    'name' => 'Fabien',
    'locale' => 'fr',
  ), UrlGeneratorInterface::NETWORK_PATH), 'network path with different host');
  $this
    ->assertSame('//fr.example.com/app.php/Fabien?query=string', $this
    ->getGenerator($routes, array(
    'host' => 'fr.example.com',
  ))
    ->generate('test', array(
    'name' => 'Fabien',
    'locale' => 'fr',
    'query' => 'string',
  ), UrlGeneratorInterface::NETWORK_PATH), 'network path although host same as context');
  $this
    ->assertSame('http://fr.example.com/app.php/Fabien', $this
    ->getGenerator($routes, array(
    'scheme' => 'https',
  ))
    ->generate('test', array(
    'name' => 'Fabien',
    'locale' => 'fr',
  ), UrlGeneratorInterface::NETWORK_PATH), 'absolute URL because scheme requirement does not match context');
  $this
    ->assertSame('http://fr.example.com/app.php/Fabien', $this
    ->getGenerator($routes)
    ->generate('test', array(
    'name' => 'Fabien',
    'locale' => 'fr',
  ), UrlGeneratorInterface::ABSOLUTE_URL), 'absolute URL with same scheme because it is requested');
}