@@ -140,9 +140,10 @@ public function testUriStringAbsolute()
140140 $ _SERVER ['HTTP_HOST ' ] = 'example.com ' ;
141141 $ _SERVER ['REQUEST_URI ' ] = '/assets/image.jpg ' ;
142142
143- $ request = Services:: request ( $ this -> config );
144- $ request -> uri = new URI ( ' http://example.com/assets/image.jpg ' );
143+ $ uri = new URI ( ' http://example.com/assets/image.jpg ' );
144+ Services:: injectMock ( ' uri ' , $ uri );
145145
146+ $ request = Services::request ($ this ->config );
146147 Services::injectMock ('request ' , $ request );
147148
148149 $ this ->assertSame ('assets/image.jpg ' , uri_string ());
@@ -153,9 +154,10 @@ public function testUriStringRelative()
153154 $ _SERVER ['HTTP_HOST ' ] = 'example.com ' ;
154155 $ _SERVER ['REQUEST_URI ' ] = '/assets/image.jpg ' ;
155156
156- $ request = Services:: request ( $ this -> config );
157- $ request -> uri = new URI ( ' http://example.com/assets/image.jpg ' );
157+ $ uri = new URI ( ' http://example.com/assets/image.jpg ' );
158+ Services:: injectMock ( ' uri ' , $ uri );
158159
160+ $ request = Services::request ($ this ->config );
159161 Services::injectMock ('request ' , $ request );
160162
161163 $ this ->assertSame ('assets/image.jpg ' , uri_string (true ));
@@ -167,9 +169,11 @@ public function testUriStringNoTrailingSlashAbsolute()
167169 $ _SERVER ['REQUEST_URI ' ] = '/assets/image.jpg ' ;
168170
169171 $ this ->config ->baseURL = 'http://example.com ' ;
170- $ request = Services::request ($ this ->config );
171- $ request ->uri = new URI ('http://example.com/assets/image.jpg ' );
172172
173+ $ uri = new URI ('http://example.com/assets/image.jpg ' );
174+ Services::injectMock ('uri ' , $ uri );
175+
176+ $ request = Services::request ($ this ->config );
173177 Services::injectMock ('request ' , $ request );
174178
175179 $ this ->assertSame ('assets/image.jpg ' , uri_string ());
@@ -181,29 +185,33 @@ public function testUriStringNoTrailingSlashRelative()
181185 $ _SERVER ['REQUEST_URI ' ] = '/assets/image.jpg ' ;
182186
183187 $ this ->config ->baseURL = 'http://example.com ' ;
184- $ request = Services::request ($ this ->config );
185- $ request ->uri = new URI ('http://example.com/assets/image.jpg ' );
186188
189+ $ uri = new URI ('http://example.com/assets/image.jpg ' );
190+ Services::injectMock ('uri ' , $ uri );
191+
192+ $ request = Services::request ($ this ->config );
187193 Services::injectMock ('request ' , $ request );
188194
189195 $ this ->assertSame ('assets/image.jpg ' , uri_string (true ));
190196 }
191197
192198 public function testUriStringEmptyAbsolute ()
193199 {
194- $ request = Services:: request ( $ this -> config );
195- $ request -> uri = new URI ( ' http://example.com/ ' );
200+ $ uri = new URI ( ' http://example.com/ ' );
201+ Services:: injectMock ( ' uri ' , $ uri );
196202
203+ $ request = Services::request ($ this ->config );
197204 Services::injectMock ('request ' , $ request );
198205
199206 $ this ->assertSame ('/ ' , uri_string ());
200207 }
201208
202209 public function testUriStringEmptyRelative ()
203210 {
204- $ request = Services:: request ( $ this -> config );
205- $ request -> uri = new URI ( ' http://example.com/ ' );
211+ $ uri = new URI ( ' http://example.com/ ' );
212+ Services:: injectMock ( ' uri ' , $ uri );
206213
214+ $ request = Services::request ($ this ->config );
207215 Services::injectMock ('request ' , $ request );
208216
209217 $ this ->assertSame ('' , uri_string (true ));
@@ -215,9 +223,11 @@ public function testUriStringSubfolderAbsolute()
215223 $ _SERVER ['REQUEST_URI ' ] = '/subfolder/assets/image.jpg ' ;
216224
217225 $ this ->config ->baseURL = 'http://example.com/subfolder/ ' ;
218- $ request = Services::request ($ this ->config );
219- $ request ->uri = new URI ('http://example.com/subfolder/assets/image.jpg ' );
220226
227+ $ uri = new URI ('http://example.com/subfolder/assets/image.jpg ' );
228+ Services::injectMock ('uri ' , $ uri );
229+
230+ $ request = Services::request ($ this ->config );
221231 Services::injectMock ('request ' , $ request );
222232
223233 $ this ->assertSame ('subfolder/assets/image.jpg ' , uri_string ());
@@ -230,8 +240,11 @@ public function testUriStringSubfolderRelative()
230240 $ _SERVER ['SCRIPT_NAME ' ] = '/subfolder/index.php ' ;
231241
232242 $ this ->config ->baseURL = 'http://example.com/subfolder/ ' ;
233- $ request = Services::request ($ this ->config );
234- $ request ->uri = new URI ('http://example.com/subfolder/assets/image.jpg ' );
243+
244+ $ uri = new URI ('http://example.com/subfolder/assets/image.jpg ' );
245+ Services::injectMock ('uri ' , $ uri );
246+
247+ $ request = Services::request ($ this ->config );
235248
236249 Services::injectMock ('request ' , $ request );
237250
@@ -287,8 +300,10 @@ public function testUrlIs(string $currentPath, string $testPath, bool $expected)
287300 $ _SERVER ['HTTP_HOST ' ] = 'example.com ' ;
288301 $ _SERVER ['REQUEST_URI ' ] = '/ ' . $ currentPath ;
289302
290- $ request = Services::request ();
291- $ request ->uri = new URI ('http://example.com/ ' . $ currentPath );
303+ $ uri = new URI ('http://example.com/ ' . $ currentPath );
304+ Services::injectMock ('uri ' , $ uri );
305+
306+ $ request = Services::request ();
292307 Services::injectMock ('request ' , $ request );
293308
294309 $ this ->assertSame ($ expected , url_is ($ testPath ));
@@ -299,12 +314,15 @@ public function testUrlIs(string $currentPath, string $testPath, bool $expected)
299314 */
300315 public function testUrlIsNoIndex (string $ currentPath , string $ testPath , bool $ expected )
301316 {
302- $ _SERVER ['HTTP_HOST ' ] = 'example.com ' ;
303- $ _SERVER ['REQUEST_URI ' ] = '/ ' . $ currentPath ;
317+ $ _SERVER ['HTTP_HOST ' ] = 'example.com ' ;
318+ $ _SERVER ['REQUEST_URI ' ] = '/ ' . $ currentPath ;
319+
304320 $ this ->config ->indexPage = '' ;
305321
306- $ request = Services::request ($ this ->config );
307- $ request ->uri = new URI ('http://example.com/ ' . $ currentPath );
322+ $ uri = new URI ('http://example.com/ ' . $ currentPath );
323+ Services::injectMock ('uri ' , $ uri );
324+
325+ $ request = Services::request ($ this ->config );
308326 Services::injectMock ('request ' , $ request );
309327
310328 $ this ->assertSame ($ expected , url_is ($ testPath ));
@@ -318,10 +336,13 @@ public function testUrlIsWithSubfolder(string $currentPath, string $testPath, bo
318336 $ _SERVER ['HTTP_HOST ' ] = 'example.com ' ;
319337 $ _SERVER ['REQUEST_URI ' ] = '/ ' . $ currentPath ;
320338 $ _SERVER ['SCRIPT_NAME ' ] = '/subfolder/index.php ' ;
321- $ this ->config ->baseURL = 'http://example.com/subfolder/ ' ;
322339
323- $ request = Services::request ($ this ->config );
324- $ request ->uri = new URI ('http://example.com/subfolder/ ' . $ currentPath );
340+ $ this ->config ->baseURL = 'http://example.com/subfolder/ ' ;
341+
342+ $ uri = new URI ('http://example.com/subfolder/ ' . $ currentPath );
343+ Services::injectMock ('uri ' , $ uri );
344+
345+ $ request = Services::request ($ this ->config );
325346 Services::injectMock ('request ' , $ request );
326347
327348 $ this ->assertSame ($ expected , url_is ($ testPath ));
0 commit comments