@@ -201,8 +201,12 @@ public function testAutoRouteFindsDefaultControllerAndMethod(): void
201
201
$ this ->collection ->setDefaultMethod ('test ' );
202
202
$ router = new Router ($ this ->collection , $ this ->request );
203
203
204
+ copy (TESTPATH . 'system/Router/Controllers/Test.php ' , APPPATH . 'Controllers/Test.php ' );
205
+
204
206
$ router ->autoRoute ('/ ' );
205
207
208
+ unlink (APPPATH . 'Controllers/Test.php ' );
209
+
206
210
$ this ->assertSame ('Test ' , $ router ->controllerName ());
207
211
$ this ->assertSame ('test ' , $ router ->methodName ());
208
212
}
@@ -212,9 +216,9 @@ public function testAutoRouteFindsControllerWithFileAndMethod(): void
212
216
$ this ->collection ->setAutoRoute (true );
213
217
$ router = new Router ($ this ->collection , $ this ->request );
214
218
215
- copy (TESTPATH . 'system/Router/Controllers/MyController .php ' , APPPATH . 'Controllers/Mycontroller.php ' );
219
+ copy (TESTPATH . 'system/Router/Controllers/Mycontroller .php ' , APPPATH . 'Controllers/Mycontroller.php ' );
216
220
217
- $ router ->autoRoute ('Mycontroller /getSomemethod ' );
221
+ $ router ->autoRoute ('mycontroller /getSomemethod ' );
218
222
219
223
unlink (APPPATH . 'Controllers/Mycontroller.php ' );
220
224
@@ -227,7 +231,7 @@ public function testAutoRouteFindsControllerWithFile(): void
227
231
$ this ->collection ->setAutoRoute (true );
228
232
$ router = new Router ($ this ->collection , $ this ->request );
229
233
230
- copy (TESTPATH . 'system/Router/Controllers/MyController .php ' , APPPATH . 'Controllers/Mycontroller.php ' );
234
+ copy (TESTPATH . 'system/Router/Controllers/Mycontroller .php ' , APPPATH . 'Controllers/Mycontroller.php ' );
231
235
232
236
$ router ->autoRoute ('mycontroller ' );
233
237
@@ -244,9 +248,9 @@ public function testAutoRouteFindsControllerWithSubfolder(): void
244
248
245
249
mkdir (APPPATH . 'Controllers/Subfolder ' );
246
250
247
- copy (TESTPATH . 'system/Router/Controllers/Subfolder/MyController .php ' , APPPATH . 'Controllers/Subfolder/Mycontroller.php ' );
251
+ copy (TESTPATH . 'system/Router/Controllers/Subfolder/Mycontroller .php ' , APPPATH . 'Controllers/Subfolder/Mycontroller.php ' );
248
252
249
- $ router ->autoRoute ('subfolder/Mycontroller /getSomemethod ' );
253
+ $ router ->autoRoute ('subfolder/mycontroller /getSomemethod ' );
250
254
251
255
unlink (APPPATH . 'Controllers/Subfolder/Mycontroller.php ' );
252
256
@@ -263,9 +267,11 @@ public function testAutoRouteFindsDashedSubfolder(): void
263
267
$ router ->setTranslateURIDashes (true );
264
268
265
269
mkdir (APPPATH . 'Controllers/Dash_folder ' );
270
+ copy (TESTPATH . 'system/Router/Controllers/Dash_folder/Mycontroller.php ' , APPPATH . 'Controllers/Dash_folder/Mycontroller.php ' );
266
271
267
272
$ router ->autoRoute ('dash-folder/mycontroller/somemethod ' );
268
273
274
+ unlink (APPPATH . 'Controllers/Dash_folder/Mycontroller.php ' );
269
275
rmdir (APPPATH . 'Controllers/Dash_folder ' );
270
276
271
277
$ this ->assertSame ('Dash_folder/ ' , $ router ->directory ());
@@ -280,16 +286,16 @@ public function testAutoRouteFindsDashedController(): void
280
286
$ router ->setTranslateURIDashes (true );
281
287
282
288
mkdir (APPPATH . 'Controllers/Dash_folder ' );
283
- file_put_contents ( APPPATH . 'Controllers/Dash_folder/Dash_controller.php ' , ' ' );
289
+ copy ( TESTPATH . 'system/Router/ Controllers/Dash_folder/Dash_controller.php ' , APPPATH . ' Controllers/Dash_folder/Dash_controller.php ' );
284
290
285
- $ router ->autoRoute ('dash-folder/dash-controller/somemethod ' );
291
+ $ router ->autoRoute ('dash-folder/dash-controller/getSomemethod ' );
286
292
287
293
unlink (APPPATH . 'Controllers/Dash_folder/Dash_controller.php ' );
288
294
rmdir (APPPATH . 'Controllers/Dash_folder ' );
289
295
290
296
$ this ->assertSame ('Dash_folder/ ' , $ router ->directory ());
291
297
$ this ->assertSame ('Dash_controller ' , $ router ->controllerName ());
292
- $ this ->assertSame ('somemethod ' , $ router ->methodName ());
298
+ $ this ->assertSame ('getSomemethod ' , $ router ->methodName ());
293
299
}
294
300
295
301
public function testAutoRouteFindsDashedMethod (): void
@@ -299,16 +305,16 @@ public function testAutoRouteFindsDashedMethod(): void
299
305
$ router ->setTranslateURIDashes (true );
300
306
301
307
mkdir (APPPATH . 'Controllers/Dash_folder ' );
302
- file_put_contents ( APPPATH . 'Controllers/Dash_folder/Dash_controller.php ' , ' ' );
308
+ copy ( TESTPATH . 'system/Router/ Controllers/Dash_folder/Dash_controller.php ' , APPPATH . ' Controllers/Dash_folder/Dash_controller.php ' );
303
309
304
- $ router ->autoRoute ('dash-folder/dash-controller/dash-method ' );
310
+ $ router ->autoRoute ('dash-folder/dash-controller/getDash_method ' );
305
311
306
312
unlink (APPPATH . 'Controllers/Dash_folder/Dash_controller.php ' );
307
313
rmdir (APPPATH . 'Controllers/Dash_folder ' );
308
314
309
315
$ this ->assertSame ('Dash_folder/ ' , $ router ->directory ());
310
316
$ this ->assertSame ('Dash_controller ' , $ router ->controllerName ());
311
- $ this ->assertSame ('dash_method ' , $ router ->methodName ());
317
+ $ this ->assertSame ('getDash_method ' , $ router ->methodName ());
312
318
}
313
319
314
320
public function testAutoRouteFindsDefaultDashFolder (): void
@@ -318,9 +324,11 @@ public function testAutoRouteFindsDefaultDashFolder(): void
318
324
$ router ->setTranslateURIDashes (true );
319
325
320
326
mkdir (APPPATH . 'Controllers/Dash_folder ' );
327
+ copy (TESTPATH . 'system/Router/Controllers/Dash_folder/Home.php ' , APPPATH . 'Controllers/Dash_folder/Home.php ' );
321
328
322
329
$ router ->autoRoute ('dash-folder ' );
323
330
331
+ unlink (APPPATH . 'Controllers/Dash_folder/Home.php ' );
324
332
rmdir (APPPATH . 'Controllers/Dash_folder ' );
325
333
326
334
$ this ->assertSame ('Dash_folder/ ' , $ router ->directory ());
@@ -335,9 +343,11 @@ public function testAutoRouteFindsMByteDir(): void
335
343
$ router ->setTranslateURIDashes (true );
336
344
337
345
mkdir (APPPATH . 'Controllers/Φ ' );
346
+ copy (TESTPATH . 'system/Router/Controllers/Φ/Home.php ' , APPPATH . 'Controllers/Φ/Home.php ' );
338
347
339
348
$ router ->autoRoute ('Φ ' );
340
349
350
+ unlink (APPPATH . 'Controllers/Φ/Home.php ' );
341
351
rmdir (APPPATH . 'Controllers/Φ ' );
342
352
343
353
$ this ->assertSame ('Φ/ ' , $ router ->directory ());
@@ -351,11 +361,11 @@ public function testAutoRouteFindsMByteController(): void
351
361
$ router = new Router ($ this ->collection , $ this ->request );
352
362
$ router ->setTranslateURIDashes (true );
353
363
354
- file_put_contents ( APPPATH . 'Controllers/Φ ' , ' ' );
364
+ copy ( TESTPATH . 'system/Router/ Controllers/Φ.php ' , APPPATH . ' Controllers/Φ.php ' );
355
365
356
366
$ router ->autoRoute ('Φ ' );
357
367
358
- unlink (APPPATH . 'Controllers/Φ ' );
368
+ unlink (APPPATH . 'Controllers/Φ.php ' );
359
369
360
370
$ this ->assertSame ('Φ ' , $ router ->controllerName ());
361
371
$ this ->assertSame ('index ' , $ router ->methodName ());
@@ -749,7 +759,11 @@ public function testTranslateURIDashesForAutoRoute(): void
749
759
$ router = new Router ($ this ->collection , $ this ->request );
750
760
$ router ->setTranslateURIDashes (true );
751
761
752
- $ router ->autoRoute ('admin-user/show-list ' );
762
+ copy (TESTPATH . 'system/Router/Controllers/Admin_user.php ' , APPPATH . 'Controllers/Admin_user.php ' );
763
+
764
+ $ router ->autoRoute ('admin_user/show_list ' );
765
+
766
+ unlink (APPPATH . 'Controllers/Admin_user.php ' );
753
767
754
768
$ this ->assertSame ('Admin_user ' , $ router ->controllerName ());
755
769
$ this ->assertSame ('show_list ' , $ router ->methodName ());
@@ -763,10 +777,14 @@ public function testAutoRouteMatchesZeroParams(): void
763
777
$ this ->collection ->setAutoRoute (true );
764
778
$ router = new Router ($ this ->collection , $ this ->request );
765
779
766
- $ router -> autoRoute ( ' myController/someMethod/0/abc ' );
780
+ copy ( TESTPATH . ' system/Router/Controllers/Mycontroller.php ' , APPPATH . ' Controllers/Mycontroller.php ' );
767
781
768
- $ this ->assertSame ('MyController ' , $ router ->controllerName ());
769
- $ this ->assertSame ('someMethod ' , $ router ->methodName ());
782
+ $ router ->autoRoute ('mycontroller/getSomemethod/0/abc ' );
783
+
784
+ $ this ->assertSame ('Mycontroller ' , $ router ->controllerName ());
785
+ $ this ->assertSame ('getSomemethod ' , $ router ->methodName ());
786
+
787
+ unlink (APPPATH . 'Controllers/Mycontroller.php ' );
770
788
771
789
$ expected = [
772
790
'0 ' ,
@@ -834,9 +852,19 @@ public function testRouterPriorDirectory(): void
834
852
$ this ->collection ->setAutoRoute (true );
835
853
$ router = new Router ($ this ->collection , $ this ->request );
836
854
855
+ mkdir (APPPATH . 'Controllers/foo ' );
856
+ mkdir (APPPATH . 'Controllers/foo/bar ' );
857
+ mkdir (APPPATH . 'Controllers/foo/bar/baz ' );
858
+ copy (TESTPATH . 'system/Router/Controllers/foo/bar/baz/Some_controller.php ' , APPPATH . 'Controllers/foo/bar/baz/Some_controller.php ' );
859
+
837
860
$ router ->setDirectory ('foo/bar/baz ' , false , true );
838
861
$ router ->handle ('Some_controller/some_method/param1/param2/param3 ' );
839
862
863
+ unlink (APPPATH . 'Controllers/foo/bar/baz/Some_controller.php ' );
864
+ rmdir (APPPATH . 'Controllers/foo/bar/baz ' );
865
+ rmdir (APPPATH . 'Controllers/foo/bar ' );
866
+ rmdir (APPPATH . 'Controllers/foo ' );
867
+
840
868
$ this ->assertSame ('foo/bar/baz/ ' , $ router ->directory ());
841
869
$ this ->assertSame ('Some_controller ' , $ router ->controllerName ());
842
870
$ this ->assertSame ('some_method ' , $ router ->methodName ());
0 commit comments