setContext() public méthode

Sets the request context.
public setContext ( Symfony\Component\Routing\RequestContext $context )
$context Symfony\Component\Routing\RequestContext The context
 public function testAbsoluteUrlWithExtraParameters()
 {
     $this->routeCollection->add('test', new Route('/testing'));
     $this->generator->setContext(array('base_url' => '/app.php', 'method' => 'GET', 'host' => 'localhost', 'port' => 80, 'is_secure' => false));
     $url = $this->generator->generate('test', array('foo' => 'bar'), true);
     $this->assertEquals('http://localhost/app.php/testing?foo=bar', $url);
 }
Exemple #2
0
 public function testAbsoluteSecureUrlWithNonStandardPort()
 {
     $this->routeCollection->add('test', new Route('/testing'));
     $this->generator->setContext(array('base_url' => '/app.php', 'method' => 'GET', 'host' => 'localhost', 'port' => 8080, 'is_secure' => true));
     $url = $this->generator->generate('test', array(), true);
     $this->assertEquals('https://localhost:8080/app.php/testing', $url);
 }