/**
  * Test session termination.
  */
 public function testTerminateSession()
 {
     $test_session_id = 's123';
     $session = new Session($test_session_id, 123);
     $user_repository = new UserRepository([new AuthenticatedUser(1, '*****@*****.**', 'Ilija Studen', '123')]);
     $session_repository = new SessionRepository([new Session($test_session_id, '*****@*****.**')]);
     $browser_session_adapter = new BrowserSessionAdapter($user_repository, $session_repository, $this->cookies);
     $this->assertInstanceOf(Session::class, $session_repository->getById($test_session_id));
     $termination_transport = $browser_session_adapter->terminate($session);
     $this->assertInstanceOf(TransportInterface::class, $termination_transport);
     $this->assertNull($session_repository->getById($test_session_id));
 }
 /**
  * Test if session usage is recorded.
  */
 public function testAuthenticationRecordsSessionUsage()
 {
     $test_session_id = 's123';
     $user_repository = new UserRepository([new AuthenticatedUser(1, '*****@*****.**', 'Ilija Studen', '123')]);
     $session_repository = new SessionRepository([new Session($test_session_id, '*****@*****.**')]);
     $this->setCookie('sessid', $test_session_id);
     $this->assertSame(0, $session_repository->getUsageById($test_session_id));
     $results = (new BrowserSessionAdapter($user_repository, $session_repository, $this->cookies))->initialize($this->request);
     $this->assertInstanceOf(Transport::class, $results);
     $this->assertInstanceOf(AuthenticatedUser::class, $results->getAuthenticatedUser());
     $this->assertInstanceOf(Session::class, $results->getAuthenticatedWith());
     $this->assertSame(1, $session_repository->getUsageById($test_session_id));
 }