@@ -22,55 +22,55 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
22
22
public function testAbsoluteUrlWithPort80 ()
23
23
{
24
24
$ 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 );
26
26
27
27
$ this ->assertEquals ('http://localhost/app.php/testing ' , $ url );
28
28
}
29
29
30
30
public function testAbsoluteSecureUrlWithPort443 ()
31
31
{
32
32
$ 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 );
34
34
35
35
$ this ->assertEquals ('https://localhost/app.php/testing ' , $ url );
36
36
}
37
37
38
38
public function testAbsoluteUrlWithNonStandardPort ()
39
39
{
40
40
$ 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 );
42
42
43
43
$ this ->assertEquals ('http://localhost:8080/app.php/testing ' , $ url );
44
44
}
45
45
46
46
public function testAbsoluteSecureUrlWithNonStandardPort ()
47
47
{
48
48
$ 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 );
50
50
51
51
$ this ->assertEquals ('https://localhost:8080/app.php/testing ' , $ url );
52
52
}
53
53
54
54
public function testRelativeUrlWithoutParameters ()
55
55
{
56
56
$ 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 );
58
58
59
59
$ this ->assertEquals ('/app.php/testing ' , $ url );
60
60
}
61
61
62
62
public function testRelativeUrlWithParameter ()
63
63
{
64
64
$ 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 );
66
66
67
67
$ this ->assertEquals ('/app.php/testing/bar ' , $ url );
68
68
}
69
69
70
70
public function testRelativeUrlWithNullParameter ()
71
71
{
72
72
$ 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 );
74
74
75
75
$ this ->assertEquals ('/app.php/testing ' , $ url );
76
76
}
@@ -83,13 +83,13 @@ public function testRelativeUrlWithNullParameterButNotOptional()
83
83
$ routes = $ this ->getRoutes ('test ' , new Route ('/testing/{foo}/bar ' , array ('foo ' => null )));
84
84
// This must raise an exception because the default requirement for "foo" is "[^/]+" which is not met with these params.
85
85
// 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 );
87
87
}
88
88
89
89
public function testRelativeUrlWithOptionalZeroParameter ()
90
90
{
91
91
$ 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 );
93
93
94
94
$ this ->assertEquals ('/app.php/testing/0 ' , $ url );
95
95
}
@@ -104,23 +104,23 @@ public function testNotPassedOptionalParameterInBetween()
104
104
public function testRelativeUrlWithExtraParameters ()
105
105
{
106
106
$ 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 );
108
108
109
109
$ this ->assertEquals ('/app.php/testing?foo=bar ' , $ url );
110
110
}
111
111
112
112
public function testAbsoluteUrlWithExtraParameters ()
113
113
{
114
114
$ 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 );
116
116
117
117
$ this ->assertEquals ('http://localhost/app.php/testing?foo=bar ' , $ url );
118
118
}
119
119
120
120
public function testUrlWithNullExtraParameters ()
121
121
{
122
122
$ 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 );
124
124
125
125
$ this ->assertEquals ('http://localhost/app.php/testing ' , $ url );
126
126
}
@@ -167,7 +167,7 @@ public function testGlobalParameterHasHigherPriorityThanDefault()
167
167
public function testGenerateWithoutRoutes ()
168
168
{
169
169
$ 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 );
171
171
}
172
172
173
173
/**
@@ -176,7 +176,7 @@ public function testGenerateWithoutRoutes()
176
176
public function testGenerateForRouteWithoutMandatoryParameter ()
177
177
{
178
178
$ 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 );
180
180
}
181
181
182
182
/**
@@ -185,7 +185,7 @@ public function testGenerateForRouteWithoutMandatoryParameter()
185
185
public function testGenerateForRouteWithInvalidOptionalParameter ()
186
186
{
187
187
$ 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 );
189
189
}
190
190
191
191
/**
@@ -194,15 +194,15 @@ public function testGenerateForRouteWithInvalidOptionalParameter()
194
194
public function testGenerateForRouteWithInvalidParameter ()
195
195
{
196
196
$ 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 );
198
198
}
199
199
200
200
public function testGenerateForRouteWithInvalidOptionalParameterNonStrict ()
201
201
{
202
202
$ routes = $ this ->getRoutes ('test ' , new Route ('/testing/{foo} ' , array ('foo ' => '1 ' ), array ('foo ' => 'd+ ' )));
203
203
$ generator = $ this ->getGenerator ($ routes );
204
204
$ 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 ));
206
206
}
207
207
208
208
public function testGenerateForRouteWithInvalidOptionalParameterNonStrictWithLogger ()
@@ -213,7 +213,7 @@ public function testGenerateForRouteWithInvalidOptionalParameterNonStrictWithLog
213
213
->method ('error ' );
214
214
$ generator = $ this ->getGenerator ($ routes , array (), $ logger );
215
215
$ 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 ));
217
217
}
218
218
219
219
public function testGenerateForRouteWithInvalidParameterButDisabledRequirementsCheck ()
@@ -230,7 +230,7 @@ public function testGenerateForRouteWithInvalidParameterButDisabledRequirementsC
230
230
public function testGenerateForRouteWithInvalidMandatoryParameter ()
231
231
{
232
232
$ 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 );
234
234
}
235
235
236
236
/**
@@ -405,7 +405,7 @@ public function testWithHostSameAsContextAndAbsolute()
405
405
{
406
406
$ routes = $ this ->getRoutes ('test ' , new Route ('/{name} ' , array (), array (), array (), '{locale}.example.com ' ));
407
407
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 ));
409
409
}
410
410
411
411
/**
@@ -414,7 +414,7 @@ public function testWithHostSameAsContextAndAbsolute()
414
414
public function testUrlWithInvalidParameterInHost ()
415
415
{
416
416
$ 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 );
418
418
}
419
419
420
420
/**
@@ -423,7 +423,7 @@ public function testUrlWithInvalidParameterInHost()
423
423
public function testUrlWithInvalidParameterInHostWhenParamHasADefaultValue ()
424
424
{
425
425
$ 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 );
427
427
}
428
428
429
429
/**
@@ -432,15 +432,15 @@ public function testUrlWithInvalidParameterInHostWhenParamHasADefaultValue()
432
432
public function testUrlWithInvalidParameterEqualsDefaultValueInHost ()
433
433
{
434
434
$ 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 );
436
436
}
437
437
438
438
public function testUrlWithInvalidParameterInHostInNonStrictMode ()
439
439
{
440
440
$ routes = $ this ->getRoutes ('test ' , new Route ('/ ' , array (), array ('foo ' => 'bar ' ), array (), '{foo}.example.com ' ));
441
441
$ generator = $ this ->getGenerator ($ routes );
442
442
$ 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 ));
444
444
}
445
445
446
446
public function testHostIsCaseInsensitive ()
0 commit comments