public function testDumpWithSchemeRequirement()
 {
     $this->routeCollection->add('Test1', new Route('/testing', array(), array(), array(), '', array('ftp', 'https')));
     $this->routeCollection->add('Test2', new Route('/testing_bc', array(), array('_scheme' => 'https')));
     // BC
     file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump(array('class' => 'SchemeUrlGenerator')));
     include $this->testTmpFilepath;
     $projectUrlGenerator = new \SchemeUrlGenerator(new RequestContext('/app.php'));
     $absoluteUrl = $projectUrlGenerator->generate('Test1', array(), true);
     $absoluteUrlBC = $projectUrlGenerator->generate('Test2', array(), true);
     $relativeUrl = $projectUrlGenerator->generate('Test1', array(), false);
     $relativeUrlBC = $projectUrlGenerator->generate('Test2', array(), false);
     $this->assertEquals($absoluteUrl, 'ftp://localhost/app.php/testing');
     $this->assertEquals($absoluteUrlBC, 'https://localhost/app.php/testing_bc');
     $this->assertEquals($relativeUrl, 'ftp://localhost/app.php/testing');
     $this->assertEquals($relativeUrlBC, 'https://localhost/app.php/testing_bc');
     $projectUrlGenerator = new \SchemeUrlGenerator(new RequestContext('/app.php', 'GET', 'localhost', 'https'));
     $absoluteUrl = $projectUrlGenerator->generate('Test1', array(), true);
     $absoluteUrlBC = $projectUrlGenerator->generate('Test2', array(), true);
     $relativeUrl = $projectUrlGenerator->generate('Test1', array(), false);
     $relativeUrlBC = $projectUrlGenerator->generate('Test2', array(), false);
     $this->assertEquals($absoluteUrl, 'https://localhost/app.php/testing');
     $this->assertEquals($absoluteUrlBC, 'https://localhost/app.php/testing_bc');
     $this->assertEquals($relativeUrl, '/app.php/testing');
     $this->assertEquals($relativeUrlBC, '/app.php/testing_bc');
 }
Exemplo n.º 2
0
 public function testDumpWithSchemeRequirement()
 {
     $this->routeCollection->add('Test1', new Route('/testing', array(), array(), array(), '', array('ftp', 'https')));
     file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump(array('class' => 'SchemeUrlGenerator')));
     include $this->testTmpFilepath;
     $projectUrlGenerator = new \SchemeUrlGenerator(new RequestContext('/app.php'));
     $absoluteUrl = $projectUrlGenerator->generate('Test1', array(), UrlGeneratorInterface::ABSOLUTE_URL);
     $relativeUrl = $projectUrlGenerator->generate('Test1', array(), UrlGeneratorInterface::ABSOLUTE_PATH);
     $this->assertEquals('ftp://localhost/app.php/testing', $absoluteUrl);
     $this->assertEquals('ftp://localhost/app.php/testing', $relativeUrl);
     $projectUrlGenerator = new \SchemeUrlGenerator(new RequestContext('/app.php', 'GET', 'localhost', 'https'));
     $absoluteUrl = $projectUrlGenerator->generate('Test1', array(), UrlGeneratorInterface::ABSOLUTE_URL);
     $relativeUrl = $projectUrlGenerator->generate('Test1', array(), UrlGeneratorInterface::ABSOLUTE_PATH);
     $this->assertEquals('https://localhost/app.php/testing', $absoluteUrl);
     $this->assertEquals('/app.php/testing', $relativeUrl);
 }