66
77use PHPUnit \Framework \Attributes \Test ;
88use Tempest \Clock \Clock ;
9+ use Tempest \DateTime \DateTimeInterface ;
910use Tempest \DateTime \Duration ;
1011use Tempest \EventBus \EventBus ;
1112use Tempest \Http \Session \Config \RedisSessionConfig ;
@@ -28,7 +29,7 @@ protected function setUp(): void
2829 {
2930 parent ::setUp ();
3031
31- $ this ->container ->config (new RedisSessionConfig (expiration: Duration::hours (2 )));
32+ $ this ->container ->config (new RedisSessionConfig (expiration: Duration::hours (2 ), prefix: ' test_session: ' ));
3233 $ this ->container ->singleton (
3334 SessionManager::class,
3435 fn () => new RedisSessionManager (
@@ -252,7 +253,7 @@ private function assertSessionNotExistsInDatabase(SessionId $sessionId): void
252253 $ this ->assertNull ($ session , "Session {$ sessionId } should not exist in database " );
253254 }
254255
255- private function getSessionLastActiveTimestamp (SessionId $ sessionId ): \ Tempest \ DateTime \ DateTime
256+ private function getSessionLastActiveTimestamp (SessionId $ sessionId ): DateTimeInterface
256257 {
257258 $ session = $ this ->getSessionFromDatabase ($ sessionId );
258259
@@ -263,11 +264,10 @@ private function getSessionLastActiveTimestamp(SessionId $sessionId): \Tempest\D
263264
264265 private function getSessionFromDatabase (SessionId $ id ): ?Session
265266 {
266- $ config = $ this ->container ->get (SessionConfig::class);
267267 $ redis = $ this ->container ->get (Redis::class);
268268
269269 try {
270- $ content = $ redis ->get (sprintf ('%s%s ' , $ config -> prefix , $ id ));
270+ $ content = $ redis ->get (sprintf ('%s%s ' , ' test_session: ' , $ id ));
271271 return unserialize ($ content , ['allowed_classes ' => true ]);
272272 } catch (Throwable ) {
273273 return null ;
0 commit comments