13
13
14
14
namespace Tests \Unit ;
15
15
16
+ use CodeIgniter \CodeIgniter ;
17
+ use CodeIgniter \Router \RouteCollection ;
18
+ use CodeIgniter \Shield \Auth ;
16
19
use Tests \Support \TestCase ;
17
20
18
21
/**
@@ -22,12 +25,18 @@ final class AuthRoutesTest extends TestCase
22
25
{
23
26
public function testRoutes (): void
24
27
{
28
+ /** @var RouteCollection $collection */
25
29
$ collection = single_service ('routes ' );
26
- $ auth = service ('auth ' );
30
+ /** @var Auth $auth */
31
+ $ auth = service ('auth ' );
27
32
28
33
$ auth ->routes ($ collection );
29
34
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
+ }
31
40
32
41
$ this ->assertArrayHasKey ('register ' , $ routes );
33
42
$ this ->assertArrayHasKey ('login ' , $ routes );
@@ -43,7 +52,11 @@ public function testRoutesExcept(): void
43
52
44
53
$ auth ->routes ($ collection , ['except ' => ['login ' ]]);
45
54
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
+ }
47
60
48
61
$ this ->assertArrayNotHasKey ('login ' , $ routes );
49
62
$ this ->assertArrayHasKey ('register ' , $ routes );
@@ -59,7 +72,11 @@ public function testRoutesCustomNamespace(): void
59
72
60
73
$ auth ->routes ($ collection , ['namespace ' => 'Auth ' ]);
61
74
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
+ }
63
80
64
81
$ this ->assertSame ('\Auth\RegisterController::registerView ' , $ routes ['register ' ]);
65
82
}
0 commit comments