16
16
use CodeIgniter \Config \Factories ;
17
17
use CodeIgniter \Config \Services ;
18
18
use CodeIgniter \Exceptions \PageNotFoundException ;
19
+ use CodeIgniter \HTTP \Method ;
19
20
use CodeIgniter \Router \Controllers \Dash_folder \Dash_controller ;
20
21
use CodeIgniter \Router \Controllers \Dash_folder \Home ;
21
22
use CodeIgniter \Router \Controllers \Index ;
@@ -42,15 +43,14 @@ protected function setUp(): void
42
43
$ this ->collection = new RouteCollection (Services::locator (), $ moduleConfig , new Routing ());
43
44
}
44
45
45
- private function createNewAutoRouter (string $ httpVerb = ' get ' , $ namespace = 'CodeIgniter\Router\Controllers ' ): AutoRouterImproved
46
+ private function createNewAutoRouter ($ namespace = 'CodeIgniter\Router\Controllers ' ): AutoRouterImproved
46
47
{
47
48
return new AutoRouterImproved (
48
49
[],
49
50
$ namespace ,
50
51
$ this ->collection ->getDefaultController (),
51
52
$ this ->collection ->getDefaultMethod (),
52
- true ,
53
- $ httpVerb
53
+ true
54
54
);
55
55
}
56
56
@@ -61,7 +61,7 @@ public function testAutoRouteFindsDefaultControllerAndMethodGet(): void
61
61
$ router = $ this ->createNewAutoRouter ();
62
62
63
63
[$ directory , $ controller , $ method , $ params ]
64
- = $ router ->getRoute ('/ ' , ' get ' );
64
+ = $ router ->getRoute ('/ ' , Method:: GET );
65
65
66
66
$ this ->assertNull ($ directory );
67
67
$ this ->assertSame ('\\' . Index::class, $ controller );
@@ -84,10 +84,10 @@ public function testAutoRouteFindsModuleDefaultControllerAndMethodGet()
84
84
85
85
$ this ->collection ->setDefaultController ('Index ' );
86
86
87
- $ router = $ this ->createNewAutoRouter ('get ' , ' App/Controllers ' );
87
+ $ router = $ this ->createNewAutoRouter ('App/Controllers ' );
88
88
89
89
[$ directory , $ controller , $ method , $ params ]
90
- = $ router ->getRoute ('test ' , ' get ' );
90
+ = $ router ->getRoute ('test ' , Method:: GET );
91
91
92
92
$ this ->assertNull ($ directory );
93
93
$ this ->assertSame ('\\' . Index::class, $ controller );
@@ -99,10 +99,10 @@ public function testAutoRouteFindsDefaultControllerAndMethodPost(): void
99
99
{
100
100
$ this ->collection ->setDefaultController ('Index ' );
101
101
102
- $ router = $ this ->createNewAutoRouter (' post ' );
102
+ $ router = $ this ->createNewAutoRouter ();
103
103
104
104
[$ directory , $ controller , $ method , $ params ]
105
- = $ router ->getRoute ('/ ' , ' post ' );
105
+ = $ router ->getRoute ('/ ' , Method:: POST );
106
106
107
107
$ this ->assertNull ($ directory );
108
108
$ this ->assertSame ('\\' . Index::class, $ controller );
@@ -115,7 +115,7 @@ public function testAutoRouteFindsControllerWithFileAndMethod(): void
115
115
$ router = $ this ->createNewAutoRouter ();
116
116
117
117
[$ directory , $ controller , $ method , $ params ]
118
- = $ router ->getRoute ('mycontroller/somemethod ' , ' get ' );
118
+ = $ router ->getRoute ('mycontroller/somemethod ' , Method:: GET );
119
119
120
120
$ this ->assertNull ($ directory );
121
121
$ this ->assertSame ('\\' . Mycontroller::class, $ controller );
@@ -133,7 +133,7 @@ public function testFindsControllerAndMethodAndParam(): void
133
133
$ router = $ this ->createNewAutoRouter ();
134
134
135
135
[$ directory , $ controller , $ method , $ params ]
136
- = $ router ->getRoute ('mycontroller/somemethod/a ' , ' get ' );
136
+ = $ router ->getRoute ('mycontroller/somemethod/a ' , Method:: GET );
137
137
138
138
$ this ->assertNull ($ directory );
139
139
$ this ->assertSame ('\\' . Mycontroller::class, $ controller );
@@ -155,15 +155,15 @@ public function testUriParamCountIsGreaterThanMethodParams(): void
155
155
156
156
$ router = $ this ->createNewAutoRouter ();
157
157
158
- $ router ->getRoute ('mycontroller/somemethod/a/b ' , ' get ' );
158
+ $ router ->getRoute ('mycontroller/somemethod/a/b ' , Method:: GET );
159
159
}
160
160
161
161
public function testAutoRouteFindsControllerWithFile (): void
162
162
{
163
163
$ router = $ this ->createNewAutoRouter ();
164
164
165
165
[$ directory , $ controller , $ method , $ params ]
166
- = $ router ->getRoute ('mycontroller ' , ' get ' );
166
+ = $ router ->getRoute ('mycontroller ' , Method:: GET );
167
167
168
168
$ this ->assertNull ($ directory );
169
169
$ this ->assertSame ('\\' . Mycontroller::class, $ controller );
@@ -176,7 +176,7 @@ public function testAutoRouteFindsControllerWithSubfolder(): void
176
176
$ router = $ this ->createNewAutoRouter ();
177
177
178
178
[$ directory , $ controller , $ method , $ params ]
179
- = $ router ->getRoute ('subfolder/mycontroller/somemethod ' , ' get ' );
179
+ = $ router ->getRoute ('subfolder/mycontroller/somemethod ' , Method:: GET );
180
180
181
181
$ this ->assertSame ('Subfolder/ ' , $ directory );
182
182
$ this ->assertSame ('\\' . \CodeIgniter \Router \Controllers \Subfolder \Mycontroller::class, $ controller );
@@ -194,7 +194,7 @@ public function testAutoRouteFindsControllerWithSubSubfolder()
194
194
$ router = $ this ->createNewAutoRouter ();
195
195
196
196
[$ directory , $ controller , $ method , $ params ]
197
- = $ router ->getRoute ('subfolder/sub/mycontroller/somemethod ' , ' get ' );
197
+ = $ router ->getRoute ('subfolder/sub/mycontroller/somemethod ' , Method:: GET );
198
198
199
199
$ this ->assertSame ('Subfolder/Sub/ ' , $ directory );
200
200
$ this ->assertSame ('\\' . \CodeIgniter \Router \Controllers \Subfolder \Sub \Mycontroller::class, $ controller );
@@ -207,7 +207,7 @@ public function testAutoRouteFindsDashedSubfolder(): void
207
207
$ router = $ this ->createNewAutoRouter ();
208
208
209
209
[$ directory , $ controller , $ method , $ params ]
210
- = $ router ->getRoute ('dash-folder/mycontroller/somemethod ' , ' get ' );
210
+ = $ router ->getRoute ('dash-folder/mycontroller/somemethod ' , Method:: GET );
211
211
212
212
$ this ->assertSame ('Dash_folder/ ' , $ directory );
213
213
$ this ->assertSame (
@@ -223,7 +223,7 @@ public function testAutoRouteFindsDashedController(): void
223
223
$ router = $ this ->createNewAutoRouter ();
224
224
225
225
[$ directory , $ controller , $ method , $ params ]
226
- = $ router ->getRoute ('dash-folder/dash-controller/somemethod ' , ' get ' );
226
+ = $ router ->getRoute ('dash-folder/dash-controller/somemethod ' , Method:: GET );
227
227
228
228
$ this ->assertSame ('Dash_folder/ ' , $ directory );
229
229
$ this ->assertSame ('\\' . Dash_controller::class, $ controller );
@@ -236,7 +236,7 @@ public function testAutoRouteFindsDashedMethod(): void
236
236
$ router = $ this ->createNewAutoRouter ();
237
237
238
238
[$ directory , $ controller , $ method , $ params ]
239
- = $ router ->getRoute ('dash-folder/dash-controller/dash-method ' , ' get ' );
239
+ = $ router ->getRoute ('dash-folder/dash-controller/dash-method ' , Method:: GET );
240
240
241
241
$ this ->assertSame ('Dash_folder/ ' , $ directory );
242
242
$ this ->assertSame ('\\' . Dash_controller::class, $ controller );
@@ -249,7 +249,7 @@ public function testAutoRouteFindsDefaultDashFolder(): void
249
249
$ router = $ this ->createNewAutoRouter ();
250
250
251
251
[$ directory , $ controller , $ method , $ params ]
252
- = $ router ->getRoute ('dash-folder ' , ' get ' );
252
+ = $ router ->getRoute ('dash-folder ' , Method:: GET );
253
253
254
254
$ this ->assertSame ('Dash_folder/ ' , $ directory );
255
255
$ this ->assertSame ('\\' . Home::class, $ controller );
@@ -262,7 +262,7 @@ public function testAutoRouteFallbackToDefaultMethod()
262
262
$ router = $ this ->createNewAutoRouter ();
263
263
264
264
[$ directory , $ controller , $ method , $ params ]
265
- = $ router ->getRoute ('index/15 ' , ' get ' );
265
+ = $ router ->getRoute ('index/15 ' , Method:: GET );
266
266
267
267
$ this ->assertNull ($ directory );
268
268
$ this ->assertSame ('\\' . Index::class, $ controller );
@@ -280,7 +280,7 @@ public function testAutoRouteFallbackToDefaultControllerOneParam()
280
280
$ router = $ this ->createNewAutoRouter ();
281
281
282
282
[$ directory , $ controller , $ method , $ params ]
283
- = $ router ->getRoute ('subfolder/15 ' , ' get ' );
283
+ = $ router ->getRoute ('subfolder/15 ' , Method:: GET );
284
284
285
285
$ this ->assertSame ('Subfolder/ ' , $ directory );
286
286
$ this ->assertSame ('\\' . \CodeIgniter \Router \Controllers \Subfolder \Home::class, $ controller );
@@ -298,7 +298,7 @@ public function testAutoRouteFallbackToDefaultControllerTwoParams()
298
298
$ router = $ this ->createNewAutoRouter ();
299
299
300
300
[$ directory , $ controller , $ method , $ params ]
301
- = $ router ->getRoute ('subfolder/15/20 ' , ' get ' );
301
+ = $ router ->getRoute ('subfolder/15/20 ' , Method:: GET );
302
302
303
303
$ this ->assertSame ('Subfolder/ ' , $ directory );
304
304
$ this ->assertSame ('\\' . \CodeIgniter \Router \Controllers \Subfolder \Home::class, $ controller );
@@ -316,7 +316,7 @@ public function testAutoRouteFallbackToDefaultControllerNoParams()
316
316
$ router = $ this ->createNewAutoRouter ();
317
317
318
318
[$ directory , $ controller , $ method , $ params ]
319
- = $ router ->getRoute ('subfolder ' , ' get ' );
319
+ = $ router ->getRoute ('subfolder ' , Method:: GET );
320
320
321
321
$ this ->assertSame ('Subfolder/ ' , $ directory );
322
322
$ this ->assertSame ('\\' . \CodeIgniter \Router \Controllers \Subfolder \Home::class, $ controller );
@@ -335,7 +335,7 @@ public function testAutoRouteRejectsSingleDot(): void
335
335
336
336
$ router = $ this ->createNewAutoRouter ();
337
337
338
- $ router ->getRoute ('. ' , ' get ' );
338
+ $ router ->getRoute ('. ' , Method:: GET );
339
339
}
340
340
341
341
public function testAutoRouteRejectsDoubleDot (): void
@@ -344,7 +344,7 @@ public function testAutoRouteRejectsDoubleDot(): void
344
344
345
345
$ router = $ this ->createNewAutoRouter ();
346
346
347
- $ router ->getRoute ('.. ' , ' get ' );
347
+ $ router ->getRoute ('.. ' , Method:: GET );
348
348
}
349
349
350
350
public function testAutoRouteRejectsMidDot (): void
@@ -353,7 +353,7 @@ public function testAutoRouteRejectsMidDot(): void
353
353
354
354
$ router = $ this ->createNewAutoRouter ();
355
355
356
- $ router ->getRoute ('foo.bar ' , ' get ' );
356
+ $ router ->getRoute ('foo.bar ' , Method:: GET );
357
357
}
358
358
359
359
public function testRejectsDefaultControllerPath (): void
@@ -362,7 +362,7 @@ public function testRejectsDefaultControllerPath(): void
362
362
363
363
$ router = $ this ->createNewAutoRouter ();
364
364
365
- $ router ->getRoute ('home ' , ' get ' );
365
+ $ router ->getRoute ('home ' , Method:: GET );
366
366
}
367
367
368
368
public function testRejectsDefaultControllerAndDefaultMethodPath (): void
@@ -371,7 +371,7 @@ public function testRejectsDefaultControllerAndDefaultMethodPath(): void
371
371
372
372
$ router = $ this ->createNewAutoRouter ();
373
373
374
- $ router ->getRoute ('home/index ' , ' get ' );
374
+ $ router ->getRoute ('home/index ' , Method:: GET );
375
375
}
376
376
377
377
public function testRejectsDefaultMethodPath (): void
@@ -380,7 +380,7 @@ public function testRejectsDefaultMethodPath(): void
380
380
381
381
$ router = $ this ->createNewAutoRouter ();
382
382
383
- $ router ->getRoute ('mycontroller/index ' , ' get ' );
383
+ $ router ->getRoute ('mycontroller/index ' , Method:: GET );
384
384
}
385
385
386
386
public function testRejectsControllerWithRemapMethod (): void
@@ -392,7 +392,7 @@ public function testRejectsControllerWithRemapMethod(): void
392
392
393
393
$ router = $ this ->createNewAutoRouter ();
394
394
395
- $ router ->getRoute ('remap/test ' , ' get ' );
395
+ $ router ->getRoute ('remap/test ' , Method:: GET );
396
396
}
397
397
398
398
public function testRejectsURIWithUnderscoreFolder ()
@@ -404,7 +404,7 @@ public function testRejectsURIWithUnderscoreFolder()
404
404
405
405
$ router = $ this ->createNewAutoRouter ();
406
406
407
- $ router ->getRoute ('dash_folder ' , ' get ' );
407
+ $ router ->getRoute ('dash_folder ' , Method:: GET );
408
408
}
409
409
410
410
public function testRejectsURIWithUnderscoreController ()
@@ -416,7 +416,7 @@ public function testRejectsURIWithUnderscoreController()
416
416
417
417
$ router = $ this ->createNewAutoRouter ();
418
418
419
- $ router ->getRoute ('dash-folder/dash_controller/dash-method ' , ' get ' );
419
+ $ router ->getRoute ('dash-folder/dash_controller/dash-method ' , Method:: GET );
420
420
}
421
421
422
422
public function testRejectsURIWithUnderscoreMethod ()
@@ -428,15 +428,15 @@ public function testRejectsURIWithUnderscoreMethod()
428
428
429
429
$ router = $ this ->createNewAutoRouter ();
430
430
431
- $ router ->getRoute ('dash-folder/dash-controller/dash_method ' , ' get ' );
431
+ $ router ->getRoute ('dash-folder/dash-controller/dash_method ' , Method:: GET );
432
432
}
433
433
434
434
public function testPermitsURIWithUnderscoreParam ()
435
435
{
436
436
$ router = $ this ->createNewAutoRouter ();
437
437
438
438
[$ directory , $ controller , $ method , $ params ]
439
- = $ router ->getRoute ('mycontroller/somemethod/a_b ' , ' get ' );
439
+ = $ router ->getRoute ('mycontroller/somemethod/a_b ' , Method:: GET );
440
440
441
441
$ this ->assertNull ($ directory );
442
442
$ this ->assertSame ('\\' . Mycontroller::class, $ controller );
@@ -449,7 +449,7 @@ public function testDoesNotTranslateDashInParam()
449
449
$ router = $ this ->createNewAutoRouter ();
450
450
451
451
[$ directory , $ controller , $ method , $ params ]
452
- = $ router ->getRoute ('mycontroller/somemethod/a-b ' , ' get ' );
452
+ = $ router ->getRoute ('mycontroller/somemethod/a-b ' , Method:: GET );
453
453
454
454
$ this ->assertNull ($ directory );
455
455
$ this ->assertSame ('\\' . Mycontroller::class, $ controller );
0 commit comments