@@ -32,9 +32,22 @@ public function testConstructor()
3232
3333 $ uri = new SiteURI ($ config );
3434
35+ $ this ->assertInstanceOf (SiteURI::class, $ uri );
36+ $ this ->assertSame ('http://example.com/index.php ' , (string ) $ uri );
37+ $ this ->assertSame ('' , $ uri ->getRoutePath ());
38+ $ this ->assertSame ('/index.php ' , $ uri ->getPath ());
39+ $ this ->assertSame ('http://example.com/ ' , $ uri ->getBaseURL ());
40+ }
41+
42+ public function testConstructorPathSlash ()
43+ {
44+ $ config = new App ();
45+
46+ $ uri = new SiteURI ($ config , '/ ' );
47+
3548 $ this ->assertInstanceOf (SiteURI::class, $ uri );
3649 $ this ->assertSame ('http://example.com/index.php/ ' , (string ) $ uri );
37- $ this ->assertSame ('/ ' , $ uri ->getRoutePath ());
50+ $ this ->assertSame ('' , $ uri ->getRoutePath ());
3851 $ this ->assertSame ('/index.php/ ' , $ uri ->getPath ());
3952 $ this ->assertSame ('http://example.com/ ' , $ uri ->getBaseURL ());
4053 }
@@ -107,9 +120,9 @@ public function testConstructorHost()
107120 $ uri = new SiteURI ($ config , '' , 'sub.example.com ' );
108121
109122 $ this ->assertInstanceOf (SiteURI::class, $ uri );
110- $ this ->assertSame ('http://sub.example.com/index.php/ ' , (string ) $ uri );
111- $ this ->assertSame ('/ ' , $ uri ->getRoutePath ());
112- $ this ->assertSame ('/index.php/ ' , $ uri ->getPath ());
123+ $ this ->assertSame ('http://sub.example.com/index.php ' , (string ) $ uri );
124+ $ this ->assertSame ('' , $ uri ->getRoutePath ());
125+ $ this ->assertSame ('/index.php ' , $ uri ->getPath ());
113126 $ this ->assertSame ('http://sub.example.com/ ' , $ uri ->getBaseURL ());
114127 }
115128
@@ -120,7 +133,7 @@ public function testConstructorScheme()
120133 $ uri = new SiteURI ($ config , '' , null , 'https ' );
121134
122135 $ this ->assertInstanceOf (SiteURI::class, $ uri );
123- $ this ->assertSame ('https://example.com/index.php/ ' , (string ) $ uri );
136+ $ this ->assertSame ('https://example.com/index.php ' , (string ) $ uri );
124137 $ this ->assertSame ('https://example.com/ ' , $ uri ->getBaseURL ());
125138 }
126139
@@ -132,9 +145,9 @@ public function testConstructorSubfolder()
132145 $ uri = new SiteURI ($ config );
133146
134147 $ this ->assertInstanceOf (SiteURI::class, $ uri );
135- $ this ->assertSame ('http://example.com/ci4/index.php/ ' , (string ) $ uri );
136- $ this ->assertSame ('/ ' , $ uri ->getRoutePath ());
137- $ this ->assertSame ('/ci4/index.php/ ' , $ uri ->getPath ());
148+ $ this ->assertSame ('http://example.com/ci4/index.php ' , (string ) $ uri );
149+ $ this ->assertSame ('' , $ uri ->getRoutePath ());
150+ $ this ->assertSame ('/ci4/index.php ' , $ uri ->getPath ());
138151 $ this ->assertSame ('http://example.com/ci4/ ' , $ uri ->getBaseURL ());
139152 }
140153
@@ -158,7 +171,7 @@ public function testConstructorForceGlobalSecureRequests()
158171
159172 $ uri = new SiteURI ($ config );
160173
161- $ this ->assertSame ('https://example.com/index.php/ ' , (string ) $ uri );
174+ $ this ->assertSame ('https://example.com/index.php ' , (string ) $ uri );
162175 $ this ->assertSame ('https://example.com/ ' , $ uri ->getBaseURL ());
163176 }
164177
@@ -171,7 +184,20 @@ public function testConstructorIndexPageEmpty()
171184
172185 $ this ->assertSame ('http://example.com/ ' , (string ) $ uri );
173186 $ this ->assertSame ('http://example.com/ ' , $ uri ->getBaseURL ());
174- $ this ->assertSame ('/ ' , $ uri ->getRoutePath ());
187+ $ this ->assertSame ('' , $ uri ->getRoutePath ());
188+ $ this ->assertSame ('/ ' , $ uri ->getPath ());
189+ }
190+
191+ public function testConstructorIndexPageEmptyWithPathSlash ()
192+ {
193+ $ config = new App ();
194+ $ config ->indexPage = '' ;
195+
196+ $ uri = new SiteURI ($ config , '/ ' );
197+
198+ $ this ->assertSame ('http://example.com/ ' , (string ) $ uri );
199+ $ this ->assertSame ('http://example.com/ ' , $ uri ->getBaseURL ());
200+ $ this ->assertSame ('' , $ uri ->getRoutePath ());
175201 $ this ->assertSame ('/ ' , $ uri ->getPath ());
176202 }
177203
@@ -242,8 +268,23 @@ public function testSetPathEmpty()
242268
243269 $ uri ->setPath ('' );
244270
271+ $ this ->assertSame ('http://example.com/index.php ' , (string ) $ uri );
272+ $ this ->assertSame ('' , $ uri ->getRoutePath ());
273+ $ this ->assertSame ('/index.php ' , $ uri ->getPath ());
274+ $ this ->assertSame ([], $ uri ->getSegments ());
275+ $ this ->assertSame (0 , $ uri ->getTotalSegments ());
276+ }
277+
278+ public function testSetPathSlash ()
279+ {
280+ $ config = new App ();
281+
282+ $ uri = new SiteURI ($ config );
283+
284+ $ uri ->setPath ('/ ' );
285+
245286 $ this ->assertSame ('http://example.com/index.php/ ' , (string ) $ uri );
246- $ this ->assertSame ('/ ' , $ uri ->getRoutePath ());
287+ $ this ->assertSame ('' , $ uri ->getRoutePath ());
247288 $ this ->assertSame ('/index.php/ ' , $ uri ->getPath ());
248289 $ this ->assertSame ([], $ uri ->getSegments ());
249290 $ this ->assertSame (0 , $ uri ->getTotalSegments ());
@@ -322,7 +363,7 @@ public function testGetRoutePath()
322363 $ config = new App ();
323364 $ uri = new SiteURI ($ config );
324365
325- $ this ->assertSame ('/ ' , $ uri ->getRoutePath ());
366+ $ this ->assertSame ('' , $ uri ->getRoutePath ());
326367 }
327368
328369 public function testGetSegments ()
0 commit comments