@@ -579,28 +579,27 @@ public function testHostIsCaseInsensitive()
579
579
580
580
public function testDefaultHostIsUsedWhenContextHostIsEmpty ()
581
581
{
582
- $ routes = $ this ->getRoutes ('test ' , new Route ('/route ' , ['domain ' => 'my.fallback.host ' ], ['domain ' => '.+ ' ], [], '{domain} ' , [ ' http ' ] ));
582
+ $ routes = $ this ->getRoutes ('test ' , new Route ('/path ' , ['domain ' => 'my.fallback.host ' ], ['domain ' => '.+ ' ], [], '{domain} ' ));
583
583
584
584
$ generator = $ this ->getGenerator ($ routes );
585
585
$ generator ->getContext ()->setHost ('' );
586
586
587
- $ this ->assertSame ('http://my.fallback.host/app.php/route ' , $ generator ->generate ('test ' , [], UrlGeneratorInterface::ABSOLUTE_URL ));
587
+ $ this ->assertSame ('http://my.fallback.host/app.php/path ' , $ generator ->generate ('test ' , [], UrlGeneratorInterface::ABSOLUTE_URL ));
588
588
}
589
589
590
- public function testDefaultHostIsUsedWhenContextHostIsEmptyAndSchemeIsNot ()
590
+ public function testDefaultHostIsUsedWhenContextHostIsEmptyAndPathReferenceType ()
591
591
{
592
- $ routes = $ this ->getRoutes ('test ' , new Route ('/route ' , ['domain ' => 'my.fallback.host ' ], ['domain ' => '.+ ' ], [], '{domain} ' , [ ' http ' , ' https ' ] ));
592
+ $ routes = $ this ->getRoutes ('test ' , new Route ('/path ' , ['domain ' => 'my.fallback.host ' ], ['domain ' => '.+ ' ], [], '{domain} ' ));
593
593
594
594
$ generator = $ this ->getGenerator ($ routes );
595
595
$ generator ->getContext ()->setHost ('' );
596
- $ generator ->getContext ()->setScheme ('https ' );
597
596
598
- $ this ->assertSame ('https: //my.fallback.host/app.php/route ' , $ generator ->generate ('test ' , [], UrlGeneratorInterface::ABSOLUTE_URL ));
597
+ $ this ->assertSame ('//my.fallback.host/app.php/path ' , $ generator ->generate ('test ' , [], UrlGeneratorInterface::ABSOLUTE_PATH ));
599
598
}
600
599
601
- public function testAbsoluteUrlFallbackToRelativeIfHostIsEmptyAndSchemeIsNot ()
600
+ public function testAbsoluteUrlFallbackToPathIfHostIsEmptyAndSchemeIsHttp ()
602
601
{
603
- $ routes = $ this ->getRoutes ('test ' , new Route ('/route ' , [], [], [], '' , [ ' http ' , ' https ' ] ));
602
+ $ routes = $ this ->getRoutes ('test ' , new Route ('/route ' ));
604
603
605
604
$ generator = $ this ->getGenerator ($ routes );
606
605
$ generator ->getContext ()->setHost ('' );
@@ -609,6 +608,39 @@ public function testAbsoluteUrlFallbackToRelativeIfHostIsEmptyAndSchemeIsNot()
609
608
$ this ->assertSame ('/app.php/route ' , $ generator ->generate ('test ' , [], UrlGeneratorInterface::ABSOLUTE_URL ));
610
609
}
611
610
611
+ public function testAbsoluteUrlFallbackToNetworkIfSchemeIsEmptyAndHostIsNot ()
612
+ {
613
+ $ routes = $ this ->getRoutes ('test ' , new Route ('/path ' ));
614
+
615
+ $ generator = $ this ->getGenerator ($ routes );
616
+ $ generator ->getContext ()->setHost ('example.com ' );
617
+ $ generator ->getContext ()->setScheme ('' );
618
+
619
+ $ this ->assertSame ('//example.com/app.php/path ' , $ generator ->generate ('test ' , [], UrlGeneratorInterface::ABSOLUTE_URL ));
620
+ }
621
+
622
+ public function testAbsoluteUrlFallbackToPathIfSchemeAndHostAreEmpty ()
623
+ {
624
+ $ routes = $ this ->getRoutes ('test ' , new Route ('/path ' ));
625
+
626
+ $ generator = $ this ->getGenerator ($ routes );
627
+ $ generator ->getContext ()->setHost ('' );
628
+ $ generator ->getContext ()->setScheme ('' );
629
+
630
+ $ this ->assertSame ('/app.php/path ' , $ generator ->generate ('test ' , [], UrlGeneratorInterface::ABSOLUTE_URL ));
631
+ }
632
+
633
+ public function testAbsoluteUrlWithNonHttpSchemeAndEmptyHost ()
634
+ {
635
+ $ routes = $ this ->getRoutes ('test ' , new Route ('/path ' , [], [], [], '' , ['file ' ]));
636
+
637
+ $ generator = $ this ->getGenerator ($ routes );
638
+ $ generator ->getContext ()->setBaseUrl ('' );
639
+ $ generator ->getContext ()->setHost ('' );
640
+
641
+ $ this ->assertSame ('file:///path ' , $ generator ->generate ('test ' , [], UrlGeneratorInterface::ABSOLUTE_URL ));
642
+ }
643
+
612
644
public function testGenerateNetworkPath ()
613
645
{
614
646
$ routes = $ this ->getRoutes ('test ' , new Route ('/{name} ' , [], [], [], '{locale}.example.com ' , ['http ' ]));
0 commit comments