1313
1414namespace Tests \Unit ;
1515
16+ use CodeIgniter \CodeIgniter ;
17+ use CodeIgniter \Router \RouteCollection ;
18+ use CodeIgniter \Shield \Auth ;
1619use Tests \Support \TestCase ;
1720
1821/**
@@ -22,12 +25,18 @@ final class AuthRoutesTest extends TestCase
2225{
2326 public function testRoutes (): void
2427 {
28+ /** @var RouteCollection $collection */
2529 $ collection = single_service ('routes ' );
26- $ auth = service ('auth ' );
30+ /** @var Auth $auth */
31+ $ auth = service ('auth ' );
2732
2833 $ auth ->routes ($ collection );
2934
30- $ routes = $ collection ->getRoutes ('get ' );
35+ if (version_compare (CodeIgniter::CI_VERSION , '4.5 ' ) >= 0 ) {
36+ $ routes = $ collection ->getRoutes ('GET ' );
37+ } else {
38+ $ routes = $ collection ->getRoutes ('get ' );
39+ }
3140
3241 $ this ->assertArrayHasKey ('register ' , $ routes );
3342 $ this ->assertArrayHasKey ('login ' , $ routes );
@@ -43,7 +52,11 @@ public function testRoutesExcept(): void
4352
4453 $ auth ->routes ($ collection , ['except ' => ['login ' ]]);
4554
46- $ routes = $ collection ->getRoutes ('get ' );
55+ if (version_compare (CodeIgniter::CI_VERSION , '4.5 ' ) >= 0 ) {
56+ $ routes = $ collection ->getRoutes ('GET ' );
57+ } else {
58+ $ routes = $ collection ->getRoutes ('get ' );
59+ }
4760
4861 $ this ->assertArrayNotHasKey ('login ' , $ routes );
4962 $ this ->assertArrayHasKey ('register ' , $ routes );
@@ -59,7 +72,11 @@ public function testRoutesCustomNamespace(): void
5972
6073 $ auth ->routes ($ collection , ['namespace ' => 'Auth ' ]);
6174
62- $ routes = $ collection ->getRoutes ('get ' );
75+ if (version_compare (CodeIgniter::CI_VERSION , '4.5 ' ) >= 0 ) {
76+ $ routes = $ collection ->getRoutes ('GET ' );
77+ } else {
78+ $ routes = $ collection ->getRoutes ('get ' );
79+ }
6380
6481 $ this ->assertSame ('\Auth\RegisterController::registerView ' , $ routes ['register ' ]);
6582 }
0 commit comments