@@ -480,28 +480,27 @@ public function testHostIsCaseInsensitive()
480
480
481
481
public function testDefaultHostIsUsedWhenContextHostIsEmpty ()
482
482
{
483
- $ routes = $ this ->getRoutes ('test ' , new Route ('/route ' , ['domain ' => 'my.fallback.host ' ], ['domain ' => '.+ ' ], [], '{domain} ' , [ ' http ' ] ));
483
+ $ routes = $ this ->getRoutes ('test ' , new Route ('/path ' , ['domain ' => 'my.fallback.host ' ], ['domain ' => '.+ ' ], [], '{domain} ' ));
484
484
485
485
$ generator = $ this ->getGenerator ($ routes );
486
486
$ generator ->getContext ()->setHost ('' );
487
487
488
- $ this ->assertSame ('http://my.fallback.host/app.php/route ' , $ generator ->generate ('test ' , [], UrlGeneratorInterface::ABSOLUTE_URL ));
488
+ $ this ->assertSame ('http://my.fallback.host/app.php/path ' , $ generator ->generate ('test ' , [], UrlGeneratorInterface::ABSOLUTE_URL ));
489
489
}
490
490
491
- public function testDefaultHostIsUsedWhenContextHostIsEmptyAndSchemeIsNot ()
491
+ public function testDefaultHostIsUsedWhenContextHostIsEmptyAndPathReferenceType ()
492
492
{
493
- $ routes = $ this ->getRoutes ('test ' , new Route ('/route ' , ['domain ' => 'my.fallback.host ' ], ['domain ' => '.+ ' ], [], '{domain} ' , [ ' http ' , ' https ' ] ));
493
+ $ routes = $ this ->getRoutes ('test ' , new Route ('/path ' , ['domain ' => 'my.fallback.host ' ], ['domain ' => '.+ ' ], [], '{domain} ' ));
494
494
495
495
$ generator = $ this ->getGenerator ($ routes );
496
496
$ generator ->getContext ()->setHost ('' );
497
- $ generator ->getContext ()->setScheme ('https ' );
498
497
499
- $ this ->assertSame ('https: //my.fallback.host/app.php/route ' , $ generator ->generate ('test ' , [], UrlGeneratorInterface::ABSOLUTE_URL ));
498
+ $ this ->assertSame ('//my.fallback.host/app.php/path ' , $ generator ->generate ('test ' , [], UrlGeneratorInterface::ABSOLUTE_PATH ));
500
499
}
501
500
502
- public function testAbsoluteUrlFallbackToRelativeIfHostIsEmptyAndSchemeIsNot ()
501
+ public function testAbsoluteUrlFallbackToPathIfHostIsEmptyAndSchemeIsHttp ()
503
502
{
504
- $ routes = $ this ->getRoutes ('test ' , new Route ('/route ' , [], [], [], '' , [ ' http ' , ' https ' ] ));
503
+ $ routes = $ this ->getRoutes ('test ' , new Route ('/route ' ));
505
504
506
505
$ generator = $ this ->getGenerator ($ routes );
507
506
$ generator ->getContext ()->setHost ('' );
@@ -510,6 +509,39 @@ public function testAbsoluteUrlFallbackToRelativeIfHostIsEmptyAndSchemeIsNot()
510
509
$ this ->assertSame ('/app.php/route ' , $ generator ->generate ('test ' , [], UrlGeneratorInterface::ABSOLUTE_URL ));
511
510
}
512
511
512
+ public function testAbsoluteUrlFallbackToNetworkIfSchemeIsEmptyAndHostIsNot ()
513
+ {
514
+ $ routes = $ this ->getRoutes ('test ' , new Route ('/path ' ));
515
+
516
+ $ generator = $ this ->getGenerator ($ routes );
517
+ $ generator ->getContext ()->setHost ('example.com ' );
518
+ $ generator ->getContext ()->setScheme ('' );
519
+
520
+ $ this ->assertSame ('//example.com/app.php/path ' , $ generator ->generate ('test ' , [], UrlGeneratorInterface::ABSOLUTE_URL ));
521
+ }
522
+
523
+ public function testAbsoluteUrlFallbackToPathIfSchemeAndHostAreEmpty ()
524
+ {
525
+ $ routes = $ this ->getRoutes ('test ' , new Route ('/path ' ));
526
+
527
+ $ generator = $ this ->getGenerator ($ routes );
528
+ $ generator ->getContext ()->setHost ('' );
529
+ $ generator ->getContext ()->setScheme ('' );
530
+
531
+ $ this ->assertSame ('/app.php/path ' , $ generator ->generate ('test ' , [], UrlGeneratorInterface::ABSOLUTE_URL ));
532
+ }
533
+
534
+ public function testAbsoluteUrlWithNonHttpSchemeAndEmptyHost ()
535
+ {
536
+ $ routes = $ this ->getRoutes ('test ' , new Route ('/path ' , [], [], [], '' , ['file ' ]));
537
+
538
+ $ generator = $ this ->getGenerator ($ routes );
539
+ $ generator ->getContext ()->setBaseUrl ('' );
540
+ $ generator ->getContext ()->setHost ('' );
541
+
542
+ $ this ->assertSame ('file:///path ' , $ generator ->generate ('test ' , [], UrlGeneratorInterface::ABSOLUTE_URL ));
543
+ }
544
+
513
545
public function testGenerateNetworkPath ()
514
546
{
515
547
$ routes = $ this ->getRoutes ('test ' , new Route ('/{name} ' , [], [], [], '{locale}.example.com ' , ['http ' ]));
0 commit comments