@@ -22,55 +22,55 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
2222 public function testAbsoluteUrlWithPort80 ()
2323 {
2424 $ routes = $ this ->getRoutes ('test ' , new Route ('/testing ' ));
25- $ url = $ this ->getGenerator ($ routes )->generate ('test ' , array (), true );
25+ $ url = $ this ->getGenerator ($ routes )->generate ('test ' , array (), UrlGeneratorInterface:: ABSOLUTE_URL );
2626
2727 $ this ->assertEquals ('http://localhost/app.php/testing ' , $ url );
2828 }
2929
3030 public function testAbsoluteSecureUrlWithPort443 ()
3131 {
3232 $ routes = $ this ->getRoutes ('test ' , new Route ('/testing ' ));
33- $ url = $ this ->getGenerator ($ routes , array ('scheme ' => 'https ' ))->generate ('test ' , array (), true );
33+ $ url = $ this ->getGenerator ($ routes , array ('scheme ' => 'https ' ))->generate ('test ' , array (), UrlGeneratorInterface:: ABSOLUTE_URL );
3434
3535 $ this ->assertEquals ('https://localhost/app.php/testing ' , $ url );
3636 }
3737
3838 public function testAbsoluteUrlWithNonStandardPort ()
3939 {
4040 $ routes = $ this ->getRoutes ('test ' , new Route ('/testing ' ));
41- $ url = $ this ->getGenerator ($ routes , array ('httpPort ' => 8080 ))->generate ('test ' , array (), true );
41+ $ url = $ this ->getGenerator ($ routes , array ('httpPort ' => 8080 ))->generate ('test ' , array (), UrlGeneratorInterface:: ABSOLUTE_URL );
4242
4343 $ this ->assertEquals ('http://localhost:8080/app.php/testing ' , $ url );
4444 }
4545
4646 public function testAbsoluteSecureUrlWithNonStandardPort ()
4747 {
4848 $ routes = $ this ->getRoutes ('test ' , new Route ('/testing ' ));
49- $ url = $ this ->getGenerator ($ routes , array ('httpsPort ' => 8080 , 'scheme ' => 'https ' ))->generate ('test ' , array (), true );
49+ $ url = $ this ->getGenerator ($ routes , array ('httpsPort ' => 8080 , 'scheme ' => 'https ' ))->generate ('test ' , array (), UrlGeneratorInterface:: ABSOLUTE_URL );
5050
5151 $ this ->assertEquals ('https://localhost:8080/app.php/testing ' , $ url );
5252 }
5353
5454 public function testRelativeUrlWithoutParameters ()
5555 {
5656 $ routes = $ this ->getRoutes ('test ' , new Route ('/testing ' ));
57- $ url = $ this ->getGenerator ($ routes )->generate ('test ' , array (), false );
57+ $ url = $ this ->getGenerator ($ routes )->generate ('test ' , array (), UrlGeneratorInterface:: ABSOLUTE_PATH );
5858
5959 $ this ->assertEquals ('/app.php/testing ' , $ url );
6060 }
6161
6262 public function testRelativeUrlWithParameter ()
6363 {
6464 $ routes = $ this ->getRoutes ('test ' , new Route ('/testing/{foo} ' ));
65- $ url = $ this ->getGenerator ($ routes )->generate ('test ' , array ('foo ' => 'bar ' ), false );
65+ $ url = $ this ->getGenerator ($ routes )->generate ('test ' , array ('foo ' => 'bar ' ), UrlGeneratorInterface:: ABSOLUTE_PATH );
6666
6767 $ this ->assertEquals ('/app.php/testing/bar ' , $ url );
6868 }
6969
7070 public function testRelativeUrlWithNullParameter ()
7171 {
7272 $ routes = $ this ->getRoutes ('test ' , new Route ('/testing.{format} ' , array ('format ' => null )));
73- $ url = $ this ->getGenerator ($ routes )->generate ('test ' , array (), false );
73+ $ url = $ this ->getGenerator ($ routes )->generate ('test ' , array (), UrlGeneratorInterface:: ABSOLUTE_PATH );
7474
7575 $ this ->assertEquals ('/app.php/testing ' , $ url );
7676 }
@@ -83,13 +83,13 @@ public function testRelativeUrlWithNullParameterButNotOptional()
8383 $ routes = $ this ->getRoutes ('test ' , new Route ('/testing/{foo}/bar ' , array ('foo ' => null )));
8484 // This must raise an exception because the default requirement for "foo" is "[^/]+" which is not met with these params.
8585 // Generating path "/testing//bar" would be wrong as matching this route would fail.
86- $ this ->getGenerator ($ routes )->generate ('test ' , array (), false );
86+ $ this ->getGenerator ($ routes )->generate ('test ' , array (), UrlGeneratorInterface:: ABSOLUTE_PATH );
8787 }
8888
8989 public function testRelativeUrlWithOptionalZeroParameter ()
9090 {
9191 $ routes = $ this ->getRoutes ('test ' , new Route ('/testing/{page} ' ));
92- $ url = $ this ->getGenerator ($ routes )->generate ('test ' , array ('page ' => 0 ), false );
92+ $ url = $ this ->getGenerator ($ routes )->generate ('test ' , array ('page ' => 0 ), UrlGeneratorInterface:: ABSOLUTE_PATH );
9393
9494 $ this ->assertEquals ('/app.php/testing/0 ' , $ url );
9595 }
@@ -104,23 +104,23 @@ public function testNotPassedOptionalParameterInBetween()
104104 public function testRelativeUrlWithExtraParameters ()
105105 {
106106 $ routes = $ this ->getRoutes ('test ' , new Route ('/testing ' ));
107- $ url = $ this ->getGenerator ($ routes )->generate ('test ' , array ('foo ' => 'bar ' ), false );
107+ $ url = $ this ->getGenerator ($ routes )->generate ('test ' , array ('foo ' => 'bar ' ), UrlGeneratorInterface:: ABSOLUTE_PATH );
108108
109109 $ this ->assertEquals ('/app.php/testing?foo=bar ' , $ url );
110110 }
111111
112112 public function testAbsoluteUrlWithExtraParameters ()
113113 {
114114 $ routes = $ this ->getRoutes ('test ' , new Route ('/testing ' ));
115- $ url = $ this ->getGenerator ($ routes )->generate ('test ' , array ('foo ' => 'bar ' ), true );
115+ $ url = $ this ->getGenerator ($ routes )->generate ('test ' , array ('foo ' => 'bar ' ), UrlGeneratorInterface:: ABSOLUTE_URL );
116116
117117 $ this ->assertEquals ('http://localhost/app.php/testing?foo=bar ' , $ url );
118118 }
119119
120120 public function testUrlWithNullExtraParameters ()
121121 {
122122 $ routes = $ this ->getRoutes ('test ' , new Route ('/testing ' ));
123- $ url = $ this ->getGenerator ($ routes )->generate ('test ' , array ('foo ' => null ), true );
123+ $ url = $ this ->getGenerator ($ routes )->generate ('test ' , array ('foo ' => null ), UrlGeneratorInterface:: ABSOLUTE_URL );
124124
125125 $ this ->assertEquals ('http://localhost/app.php/testing ' , $ url );
126126 }
@@ -167,7 +167,7 @@ public function testGlobalParameterHasHigherPriorityThanDefault()
167167 public function testGenerateWithoutRoutes ()
168168 {
169169 $ routes = $ this ->getRoutes ('foo ' , new Route ('/testing/{foo} ' ));
170- $ this ->getGenerator ($ routes )->generate ('test ' , array (), true );
170+ $ this ->getGenerator ($ routes )->generate ('test ' , array (), UrlGeneratorInterface:: ABSOLUTE_URL );
171171 }
172172
173173 /**
@@ -176,7 +176,7 @@ public function testGenerateWithoutRoutes()
176176 public function testGenerateForRouteWithoutMandatoryParameter ()
177177 {
178178 $ routes = $ this ->getRoutes ('test ' , new Route ('/testing/{foo} ' ));
179- $ this ->getGenerator ($ routes )->generate ('test ' , array (), true );
179+ $ this ->getGenerator ($ routes )->generate ('test ' , array (), UrlGeneratorInterface:: ABSOLUTE_URL );
180180 }
181181
182182 /**
@@ -185,7 +185,7 @@ public function testGenerateForRouteWithoutMandatoryParameter()
185185 public function testGenerateForRouteWithInvalidOptionalParameter ()
186186 {
187187 $ routes = $ this ->getRoutes ('test ' , new Route ('/testing/{foo} ' , array ('foo ' => '1 ' ), array ('foo ' => 'd+ ' )));
188- $ this ->getGenerator ($ routes )->generate ('test ' , array ('foo ' => 'bar ' ), true );
188+ $ this ->getGenerator ($ routes )->generate ('test ' , array ('foo ' => 'bar ' ), UrlGeneratorInterface:: ABSOLUTE_URL );
189189 }
190190
191191 /**
@@ -194,15 +194,15 @@ public function testGenerateForRouteWithInvalidOptionalParameter()
194194 public function testGenerateForRouteWithInvalidParameter ()
195195 {
196196 $ routes = $ this ->getRoutes ('test ' , new Route ('/testing/{foo} ' , array (), array ('foo ' => '1|2 ' )));
197- $ this ->getGenerator ($ routes )->generate ('test ' , array ('foo ' => '0 ' ), true );
197+ $ this ->getGenerator ($ routes )->generate ('test ' , array ('foo ' => '0 ' ), UrlGeneratorInterface:: ABSOLUTE_URL );
198198 }
199199
200200 public function testGenerateForRouteWithInvalidOptionalParameterNonStrict ()
201201 {
202202 $ routes = $ this ->getRoutes ('test ' , new Route ('/testing/{foo} ' , array ('foo ' => '1 ' ), array ('foo ' => 'd+ ' )));
203203 $ generator = $ this ->getGenerator ($ routes );
204204 $ generator ->setStrictRequirements (false );
205- $ this ->assertNull ($ generator ->generate ('test ' , array ('foo ' => 'bar ' ), true ));
205+ $ this ->assertNull ($ generator ->generate ('test ' , array ('foo ' => 'bar ' ), UrlGeneratorInterface:: ABSOLUTE_URL ));
206206 }
207207
208208 public function testGenerateForRouteWithInvalidOptionalParameterNonStrictWithLogger ()
@@ -213,7 +213,7 @@ public function testGenerateForRouteWithInvalidOptionalParameterNonStrictWithLog
213213 ->method ('error ' );
214214 $ generator = $ this ->getGenerator ($ routes , array (), $ logger );
215215 $ generator ->setStrictRequirements (false );
216- $ this ->assertNull ($ generator ->generate ('test ' , array ('foo ' => 'bar ' ), true ));
216+ $ this ->assertNull ($ generator ->generate ('test ' , array ('foo ' => 'bar ' ), UrlGeneratorInterface:: ABSOLUTE_URL ));
217217 }
218218
219219 public function testGenerateForRouteWithInvalidParameterButDisabledRequirementsCheck ()
@@ -230,7 +230,7 @@ public function testGenerateForRouteWithInvalidParameterButDisabledRequirementsC
230230 public function testGenerateForRouteWithInvalidMandatoryParameter ()
231231 {
232232 $ routes = $ this ->getRoutes ('test ' , new Route ('/testing/{foo} ' , array (), array ('foo ' => 'd+ ' )));
233- $ this ->getGenerator ($ routes )->generate ('test ' , array ('foo ' => 'bar ' ), true );
233+ $ this ->getGenerator ($ routes )->generate ('test ' , array ('foo ' => 'bar ' ), UrlGeneratorInterface:: ABSOLUTE_URL );
234234 }
235235
236236 /**
@@ -405,7 +405,7 @@ public function testWithHostSameAsContextAndAbsolute()
405405 {
406406 $ routes = $ this ->getRoutes ('test ' , new Route ('/{name} ' , array (), array (), array (), '{locale}.example.com ' ));
407407
408- $ this ->assertEquals ('http://fr.example.com/app.php/Fabien ' , $ this ->getGenerator ($ routes , array ('host ' => 'fr.example.com ' ))->generate ('test ' , array ('name ' => 'Fabien ' , 'locale ' => 'fr ' ), true ));
408+ $ this ->assertEquals ('http://fr.example.com/app.php/Fabien ' , $ this ->getGenerator ($ routes , array ('host ' => 'fr.example.com ' ))->generate ('test ' , array ('name ' => 'Fabien ' , 'locale ' => 'fr ' ), UrlGeneratorInterface:: ABSOLUTE_URL ));
409409 }
410410
411411 /**
@@ -414,7 +414,7 @@ public function testWithHostSameAsContextAndAbsolute()
414414 public function testUrlWithInvalidParameterInHost ()
415415 {
416416 $ routes = $ this ->getRoutes ('test ' , new Route ('/ ' , array (), array ('foo ' => 'bar ' ), array (), '{foo}.example.com ' ));
417- $ this ->getGenerator ($ routes )->generate ('test ' , array ('foo ' => 'baz ' ), false );
417+ $ this ->getGenerator ($ routes )->generate ('test ' , array ('foo ' => 'baz ' ), UrlGeneratorInterface:: ABSOLUTE_PATH );
418418 }
419419
420420 /**
@@ -423,7 +423,7 @@ public function testUrlWithInvalidParameterInHost()
423423 public function testUrlWithInvalidParameterInHostWhenParamHasADefaultValue ()
424424 {
425425 $ routes = $ this ->getRoutes ('test ' , new Route ('/ ' , array ('foo ' => 'bar ' ), array ('foo ' => 'bar ' ), array (), '{foo}.example.com ' ));
426- $ this ->getGenerator ($ routes )->generate ('test ' , array ('foo ' => 'baz ' ), false );
426+ $ this ->getGenerator ($ routes )->generate ('test ' , array ('foo ' => 'baz ' ), UrlGeneratorInterface:: ABSOLUTE_PATH );
427427 }
428428
429429 /**
@@ -432,15 +432,15 @@ public function testUrlWithInvalidParameterInHostWhenParamHasADefaultValue()
432432 public function testUrlWithInvalidParameterEqualsDefaultValueInHost ()
433433 {
434434 $ routes = $ this ->getRoutes ('test ' , new Route ('/ ' , array ('foo ' => 'baz ' ), array ('foo ' => 'bar ' ), array (), '{foo}.example.com ' ));
435- $ this ->getGenerator ($ routes )->generate ('test ' , array ('foo ' => 'baz ' ), false );
435+ $ this ->getGenerator ($ routes )->generate ('test ' , array ('foo ' => 'baz ' ), UrlGeneratorInterface:: ABSOLUTE_PATH );
436436 }
437437
438438 public function testUrlWithInvalidParameterInHostInNonStrictMode ()
439439 {
440440 $ routes = $ this ->getRoutes ('test ' , new Route ('/ ' , array (), array ('foo ' => 'bar ' ), array (), '{foo}.example.com ' ));
441441 $ generator = $ this ->getGenerator ($ routes );
442442 $ generator ->setStrictRequirements (false );
443- $ this ->assertNull ($ generator ->generate ('test ' , array ('foo ' => 'baz ' ), false ));
443+ $ this ->assertNull ($ generator ->generate ('test ' , array ('foo ' => 'baz ' ), UrlGeneratorInterface:: ABSOLUTE_PATH ));
444444 }
445445
446446 public function testHostIsCaseInsensitive ()
0 commit comments