public function UrlGeneratorTest::testAdjacentVariables

File

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

Class

UrlGeneratorTest

Namespace

Symfony\Component\Routing\Tests\Generator

Code

public function testAdjacentVariables() {
  $routes = $this
    ->getRoutes('test', new Route('/{x}{y}{z}.{_format}', array(
    'z' => 'default-z',
    '_format' => 'html',
  ), array(
    'y' => '\\d+',
  )));
  $generator = $this
    ->getGenerator($routes);
  $this
    ->assertSame('/app.php/foo123', $generator
    ->generate('test', array(
    'x' => 'foo',
    'y' => '123',
  )));
  $this
    ->assertSame('/app.php/foo123bar.xml', $generator
    ->generate('test', array(
    'x' => 'foo',
    'y' => '123',
    'z' => 'bar',
    '_format' => 'xml',
  )));

  // The default requirement for 'x' should not allow the separator '.' in this case because it would otherwise match everything
  // and following optional variables like _format could never match.
  $this
    ->setExpectedException('Symfony\\Component\\Routing\\Exception\\InvalidParameterException');
  $generator
    ->generate('test', array(
    'x' => 'do.t',
    'y' => '123',
    'z' => 'bar',
    '_format' => 'xml',
  ));
}