You are here

public function UrlGeneratorTest::testAdjacentVariables 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::testAdjacentVariables()

File

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

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',
  ));
}