/**
  * Test session ttl expiration.
  */
 public function testAuthenticationSessionTtlDuration()
 {
     $test_session_id = 's123';
     $user_repository = new UserRepository([new AuthenticatedUser(1, '*****@*****.**', 'Ilija Studen', '123')]);
     $session = new Session($test_session_id, '*****@*****.**');
     // Check Default
     $this->assertEquals(Session::SESSION_TTL, $session->getSessionTtl());
     // Check if extended
     $session->setIsExtendedSession(true);
     $this->assertEquals(Session::EXTENDED_SESSION_TTL, $session->getSessionTtl());
 }
 /**
  * Create a new session.
  *
  * @param  AuthenticatedUserInterface $user
  * @param  array                      $credentials
  * @param  DateTimeInterface|null     $expires_at
  * @return SessionInterface
  */
 public function createSession(AuthenticatedUserInterface $user, array $credentials = [], DateTimeInterface $expires_at = null)
 {
     /** @var Session $session */
     foreach ($this->sessions as $session) {
         if ($session->getUserId() === $user->getEmail()) {
             return $session;
         }
     }
     $session = new Session(sha1(time()), $user->getUsername(), $expires_at);
     if (!empty($credentials['remember'])) {
         $session->setIsExtendedSession(true);
     }
     return $session;
 }