File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
tests/Authentication/Filters Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -45,4 +45,16 @@ public function testFilterSuccess(): void
4545 // Last Active should have been updated
4646 $ this ->assertNotEmpty (auth ('session ' )->user ()->last_active );
4747 }
48+
49+ public function testRecordActiveDate (): void
50+ {
51+ $ user = fake (UserModel::class);
52+ $ _SESSION ['user ' ]['id ' ] = $ user ->id ;
53+
54+ $ this ->withSession (['user ' => ['id ' => $ user ->id ]])
55+ ->get ('protected-route ' );
56+
57+ // Last Active should be greater than 'updated_at' column
58+ $ this ->assertGreaterThan (auth ('session ' )->user ()->updated_at , auth ('session ' )->user ()->last_active );
59+ }
4860}
Original file line number Diff line number Diff line change @@ -50,4 +50,17 @@ public function testFilterSuccess(): void
5050 $ this ->assertInstanceOf (AccessToken::class, auth ('tokens ' )->user ()->currentAccessToken ());
5151 $ this ->assertSame ($ token ->id , auth ('tokens ' )->user ()->currentAccessToken ()->id );
5252 }
53+
54+ public function testRecordActiveDate (): void
55+ {
56+ /** @var User $user */
57+ $ user = fake (UserModel::class);
58+ $ token = $ user ->generateAccessToken ('foo ' );
59+
60+ $ this ->withHeaders (['Authorization ' => 'Bearer ' . $ token ->raw_token ])
61+ ->get ('protected-route ' );
62+
63+ // Last Active should be greater than 'updated_at' column
64+ $ this ->assertGreaterThan (auth ('tokens ' )->user ()->updated_at , auth ('tokens ' )->user ()->last_active );
65+ }
5366}
You can’t perform that action at this time.
0 commit comments