Beispiel #1
0
 /**
  * @test
  * @covers SlimApp\Session::delete
  * @uses SlimApp\Session::set
  */
 public function delete_deletes_the_session_variable()
 {
     Session::set('UserId', 100);
     Session::delete('UserId');
     $result = Session::get('UserId');
     $this->assertFalse($result);
 }
Beispiel #2
0
 /**
  * Sets the current user using the UserId session variable and the data mapper
  */
 public function addLoggedInUserDataToContext()
 {
     if (Session::exists('UserId')) {
         $userId = Session::get('UserId');
         $where = '`UserId` = ' . $userId;
         $user = $this->userMapper->findRow($where);
         $this->context['user'] = $user->toArray();
     }
 }
Beispiel #3
0
 /**
  * Logs the user out, ie. detroys the session varialbe UserId, if it exists
  */
 public function logout()
 {
     if (Session::exists('UserId')) {
         Session::delete('UserId');
     }
 }
 /**
  * @test
  * @covers SlimApp\Authentication::logout
  * @uses SlimApp\Session::delete
  * @uses SlimApp\Session::set
  */
 public function logout_deletes_the_UserId_session_variable_if_it_was_set()
 {
     // Clean the session before the tests
     Session::delete('UserId');
     // Logout called by a guest user
     $authentication = new Authentication();
     $authentication->logout();
     $userIdAfterGuestLogout = Session::get('UserId');
     // Logged in user
     Session::set('UserId', 123);
     $authentication->logout();
     $userIdAfterLoggedInUserLogout = Session::get('UserId');
     $this->assertFalse($userIdAfterGuestLogout);
     $this->assertFalse($userIdAfterLoggedInUserLogout);
 }