Skip to content

Commit 0493816

Browse files
committed
Add test cases for empty host but non-empty scheme
1 parent c8ad49c commit 0493816

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,28 @@ public function testDefaultHostIsUsedWhenContextHostIsEmpty()
479479
$this->assertSame('http://my.fallback.host/app.php/route', $generator->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_URL));
480480
}
481481

482+
public function testDefaultHostIsUsedWhenContextHostIsEmptyAndSchemeIsNot()
483+
{
484+
$routes = $this->getRoutes('test', new Route('/route', array('domain' => 'my.fallback.host'), array('domain' => '.+'), array(), '{domain}', array('http', 'https')));
485+
486+
$generator = $this->getGenerator($routes);
487+
$generator->getContext()->setHost('');
488+
$generator->getContext()->setScheme('https');
489+
490+
$this->assertSame('https://my.fallback.host/app.php/route', $generator->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_URL));
491+
}
492+
493+
public function testHostIsEmptyAndSchemeIsNot()
494+
{
495+
$routes = $this->getRoutes('test', new Route('/route', array(), array(), array(), '', array('http', 'https')));
496+
497+
$generator = $this->getGenerator($routes);
498+
$generator->getContext()->setHost('');
499+
$generator->getContext()->setScheme('https');
500+
501+
$this->assertSame('https:///app.php/route', $generator->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_URL));
502+
}
503+
482504
/**
483505
* @group legacy
484506
*/

0 commit comments

Comments
 (0)