public function PhpGeneratorDumperTest::testDumpWithRoutes

File

drupal/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php, line 57

Class

PhpGeneratorDumperTest

Namespace

Symfony\Component\Routing\Tests\Generator\Dumper

Code

public function testDumpWithRoutes() {
  $this->routeCollection
    ->add('Test', new Route('/testing/{foo}'));
  $this->routeCollection
    ->add('Test2', new Route('/testing2'));
  file_put_contents($this->testTmpFilepath, $this->generatorDumper
    ->dump());
  include $this->testTmpFilepath;
  $projectUrlGenerator = new \ProjectUrlGenerator(new RequestContext('/app.php'));
  $absoluteUrlWithParameter = $projectUrlGenerator
    ->generate('Test', array(
    'foo' => 'bar',
  ), true);
  $absoluteUrlWithoutParameter = $projectUrlGenerator
    ->generate('Test2', array(), true);
  $relativeUrlWithParameter = $projectUrlGenerator
    ->generate('Test', array(
    'foo' => 'bar',
  ), false);
  $relativeUrlWithoutParameter = $projectUrlGenerator
    ->generate('Test2', array(), false);
  $this
    ->assertEquals($absoluteUrlWithParameter, 'http://localhost/app.php/testing/bar');
  $this
    ->assertEquals($absoluteUrlWithoutParameter, 'http://localhost/app.php/testing2');
  $this
    ->assertEquals($relativeUrlWithParameter, '/app.php/testing/bar');
  $this
    ->assertEquals($relativeUrlWithoutParameter, '/app.php/testing2');
}