You are here

public function PhpGeneratorDumperTest::testDumpWithRoutes in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php \Symfony\Component\Routing\Tests\Generator\Dumper\PhpGeneratorDumperTest::testDumpWithRoutes()

File

vendor/symfony/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');
}