@@ -151,17 +151,16 @@ public function testConstructorPath(string $path, string $expected)
151
151
/**
152
152
* @dataProvider configProvider
153
153
*/
154
- public function testConstructorConfig (array $ configs , string $ baseURL )
154
+ public function testConstructorConfig (array $ configs , string $ baseURL, string $ siteURL )
155
155
{
156
156
foreach ($ configs as $ key => $ value )
157
157
{
158
158
$ this ->setConfig ($ key , $ value );
159
159
}
160
160
161
- $ url = new URL ('testaroo ' , $ this ->config );
162
- $ expected = rtrim ($ baseURL , '/ ' ) . '/testaroo ' ;
161
+ $ url = new URL ('testaroo ' , $ this ->config );
163
162
164
- $ this ->assertSame ($ expected , (string ) $ url );
163
+ $ this ->assertSame ($ siteURL , (string ) $ url );
165
164
}
166
165
167
166
/**
@@ -180,7 +179,7 @@ public function testCurrent(string $uri, string $expected = null)
180
179
/**
181
180
* @dataProvider configProvider
182
181
*/
183
- public function testBase (array $ configs , string $ expected )
182
+ public function testBase (array $ configs , string $ baseURL , string $ siteURL )
184
183
{
185
184
foreach ($ configs as $ key => $ value )
186
185
{
@@ -191,7 +190,14 @@ public function testBase(array $configs, string $expected)
191
190
192
191
$ url = URL ::base ();
193
192
194
- $ this ->assertSame ($ expected , (string ) $ url );
193
+ $ this ->assertSame ($ baseURL , (string ) $ url );
194
+ }
195
+
196
+ public function testBaseWithUri ()
197
+ {
198
+ $ url = URL ::base ('images/cat.gif ' );
199
+
200
+ $ this ->assertSame ('http://example.com/images/cat.gif ' , (string ) $ url );
195
201
}
196
202
197
203
public function testTo ()
@@ -270,52 +276,60 @@ public function configProvider(): array
270
276
[
271
277
'baseURL ' => 'http://bananas.com ' ,
272
278
],
273
- 'http://bananas.com/index.php ' ,
279
+ 'http://bananas.com/ ' ,
280
+ 'http://bananas.com/index.php/testaroo ' ,
274
281
],
275
282
[
276
283
[
277
284
'baseURL ' => 'http://bananas.com/ ' ,
278
285
],
279
- 'http://bananas.com/index.php ' ,
286
+ 'http://bananas.com/ ' ,
287
+ 'http://bananas.com/index.php/testaroo ' ,
280
288
],
281
289
[
282
290
[
283
291
'baseURL ' => 'http://bananas.com/subfolder/ ' ,
284
292
],
285
- 'http://bananas.com/subfolder/index.php ' ,
293
+ 'http://bananas.com/subfolder/ ' ,
294
+ 'http://bananas.com/subfolder/index.php/testaroo ' ,
286
295
],
287
296
[
288
297
[
289
298
'indexPage ' => '' ,
290
299
],
291
300
'http://example.com/ ' ,
301
+ 'http://example.com/testaroo ' ,
292
302
],
293
303
[
294
304
[
295
305
'baseURL ' => 'http://bananas.com/subfolder/ ' ,
296
306
'indexPage ' => '' ,
297
307
],
298
308
'http://bananas.com/subfolder/ ' ,
309
+ 'http://bananas.com/subfolder/testaroo ' ,
299
310
],
300
311
[
301
312
[
302
313
'forceGlobalSecureRequests ' => true ,
303
314
],
304
- 'https://example.com/index.php ' ,
315
+ 'https://example.com/ ' ,
316
+ 'https://example.com/index.php/testaroo ' ,
305
317
],
306
318
[
307
319
[
308
320
'baseURL ' => 'http://bananas.com/ ' ,
309
321
'forceGlobalSecureRequests ' => true ,
310
322
],
311
- 'https://bananas.com/index.php ' ,
323
+ 'https://bananas.com/ ' ,
324
+ 'https://bananas.com/index.php/testaroo ' ,
312
325
],
313
326
[
314
327
[
315
328
'baseURL ' => 'https://bananas.com/subfolder/ ' ,
316
329
'forceGlobalSecureRequests ' => true ,
317
330
],
318
- 'https://bananas.com/subfolder/index.php ' ,
331
+ 'https://bananas.com/subfolder/ ' ,
332
+ 'https://bananas.com/subfolder/index.php/testaroo ' ,
319
333
],
320
334
];
321
335
}
0 commit comments