@@ -19,19 +19,20 @@ final class AuthTest extends TestCase
1919 protected $ namespace ;
2020 protected $ refresh = true ;
2121 private User $ user ;
22+ private Auth $ collector ;
2223
2324 protected function setUp (): void
2425 {
2526 parent ::setUp ();
2627
2728 $ this ->user = fake (UserModel::class, ['username ' => 'John Smith ' ]);
29+
30+ $ this ->collector = new Auth ();
2831 }
2932
3033 public function testDisplayNotLoggedIn ()
3134 {
32- $ collector = new Auth ();
33-
34- $ output = $ collector ->display ();
35+ $ output = $ this ->collector ->display ();
3536
3637 $ this ->assertStringContainsString ('Not logged in ' , $ output );
3738 }
@@ -43,12 +44,28 @@ public function testtestDisplayLoggedIn()
4344 $ authenticator ->login ($ this ->user );
4445 $ this ->user ->addGroup ('admin ' , 'beta ' );
4546
46- $ collector = new Auth ();
47-
48- $ output = $ collector ->display ();
47+ $ output = $ this ->collector ->display ();
4948
5049 $ this ->assertStringContainsString ('Current Use ' , $ output );
5150 $ this ->assertStringContainsString ('<td>Username</td><td>John Smith</td> ' , $ output );
5251 $ this ->assertStringContainsString ('<td>Groups</td><td>admin, beta</td> ' , $ output );
5352 }
53+
54+ public function testGetTitleDetails ()
55+ {
56+ $ output = $ this ->collector ->getTitleDetails ();
57+
58+ $ this ->assertStringContainsString ('CodeIgniter\Shield\Auth ' , $ output );
59+ }
60+
61+ public function testGetBadgeValueReturnsUserId ()
62+ {
63+ /** @var Session $authenticator */
64+ $ authenticator = service ('auth ' )->getAuthenticator ();
65+ $ authenticator ->login ($ this ->user );
66+
67+ $ output = (string ) $ this ->collector ->getBadgeValue ();
68+
69+ $ this ->assertStringContainsString ('1 ' , $ output );
70+ }
5471}
0 commit comments