@@ -151,17 +151,16 @@ public function testConstructorPath(string $path, string $expected)
151151 /**
152152 * @dataProvider configProvider
153153 */
154- public function testConstructorConfig (array $ configs , string $ baseURL )
154+ public function testConstructorConfig (array $ configs , string $ baseURL, string $ siteURL )
155155 {
156156 foreach ($ configs as $ key => $ value )
157157 {
158158 $ this ->setConfig ($ key , $ value );
159159 }
160160
161- $ url = new URL ('testaroo ' , $ this ->config );
162- $ expected = rtrim ($ baseURL , '/ ' ) . '/testaroo ' ;
161+ $ url = new URL ('testaroo ' , $ this ->config );
163162
164- $ this ->assertSame ($ expected , (string ) $ url );
163+ $ this ->assertSame ($ siteURL , (string ) $ url );
165164 }
166165
167166 /**
@@ -180,7 +179,7 @@ public function testCurrent(string $uri, string $expected = null)
180179 /**
181180 * @dataProvider configProvider
182181 */
183- public function testBase (array $ configs , string $ expected )
182+ public function testBase (array $ configs , string $ baseURL , string $ siteURL )
184183 {
185184 foreach ($ configs as $ key => $ value )
186185 {
@@ -191,7 +190,14 @@ public function testBase(array $configs, string $expected)
191190
192191 $ url = URL ::base ();
193192
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 );
195201 }
196202
197203 public function testTo ()
@@ -270,52 +276,60 @@ public function configProvider(): array
270276 [
271277 'baseURL ' => 'http://bananas.com ' ,
272278 ],
273- 'http://bananas.com/index.php ' ,
279+ 'http://bananas.com/ ' ,
280+ 'http://bananas.com/index.php/testaroo ' ,
274281 ],
275282 [
276283 [
277284 'baseURL ' => 'http://bananas.com/ ' ,
278285 ],
279- 'http://bananas.com/index.php ' ,
286+ 'http://bananas.com/ ' ,
287+ 'http://bananas.com/index.php/testaroo ' ,
280288 ],
281289 [
282290 [
283291 'baseURL ' => 'http://bananas.com/subfolder/ ' ,
284292 ],
285- 'http://bananas.com/subfolder/index.php ' ,
293+ 'http://bananas.com/subfolder/ ' ,
294+ 'http://bananas.com/subfolder/index.php/testaroo ' ,
286295 ],
287296 [
288297 [
289298 'indexPage ' => '' ,
290299 ],
291300 'http://example.com/ ' ,
301+ 'http://example.com/testaroo ' ,
292302 ],
293303 [
294304 [
295305 'baseURL ' => 'http://bananas.com/subfolder/ ' ,
296306 'indexPage ' => '' ,
297307 ],
298308 'http://bananas.com/subfolder/ ' ,
309+ 'http://bananas.com/subfolder/testaroo ' ,
299310 ],
300311 [
301312 [
302313 'forceGlobalSecureRequests ' => true ,
303314 ],
304- 'https://example.com/index.php ' ,
315+ 'https://example.com/ ' ,
316+ 'https://example.com/index.php/testaroo ' ,
305317 ],
306318 [
307319 [
308320 'baseURL ' => 'http://bananas.com/ ' ,
309321 'forceGlobalSecureRequests ' => true ,
310322 ],
311- 'https://bananas.com/index.php ' ,
323+ 'https://bananas.com/ ' ,
324+ 'https://bananas.com/index.php/testaroo ' ,
312325 ],
313326 [
314327 [
315328 'baseURL ' => 'https://bananas.com/subfolder/ ' ,
316329 'forceGlobalSecureRequests ' => true ,
317330 ],
318- 'https://bananas.com/subfolder/index.php ' ,
331+ 'https://bananas.com/subfolder/ ' ,
332+ 'https://bananas.com/subfolder/index.php/testaroo ' ,
319333 ],
320334 ];
321335 }
0 commit comments