public function UrlGeneratorTest::testGenerateNetworkPath

File

drupal/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php, line 450

Class

UrlGeneratorTest

Namespace

Symfony\Component\Routing\Tests\Generator

Code

public function testGenerateNetworkPath() {
  $routes = $this
    ->getRoutes('test', new Route('/{name}', array(), array(
    '_scheme' => 'http',
  ), array(), '{locale}.example.com'));
  $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');
}