Ejemplo n.º 1
0
 /**
  * Test the Auth::logout method.
  *
  * @group laravel
  */
 public function testLogoutMethodLogsOutUser()
 {
     Session::$instance = new Payload($this->getMock('Laravel\\Session\\Drivers\\Driver'));
     $data = Session::$instance->session['data']['laravel_auth_drivers_fluent_login'] = 1;
     Auth::logout();
     // A workaround since Cookie will is only stored in memory, until Response class is called.
     Auth::driver()->token = null;
     $this->assertNull(Auth::user());
     $this->assertFalse(isset(Session::$instance->session['data']['laravel_auth_drivers_fluent_login']));
     $this->assertTrue(Cookie::$jar['laravel_auth_drivers_fluent_remember']['expiration'] < time());
 }
Ejemplo n.º 2
0
 /**
  * Test the Session::started method.
  *
  * @group laravel
  */
 public function testStartedMethodIndicatesIfSessionIsStarted()
 {
     $this->assertFalse(Session::started());
     Session::$instance = 'foo';
     $this->assertTrue(Session::started());
 }
Ejemplo n.º 3
0
 /**
  * Create a fresh session array with a unique ID.
  *
  * @return array
  */
 public function fresh()
 {
     // Fetch a guest session with the same IP address
     $old_guest_session = $this->table()->where_user_id(1)->where_last_ip(Request::ip())->first();
     // We will simply generate an empty session payload array, using an ID
     // that is either not currently assigned to any existing session or
     // that belongs to a guest with the same IP address.
     if (is_null($old_guest_session)) {
         $id = $this->id();
     } else {
         $id = $old_guest_session->id;
         Session::instance()->exists = true;
     }
     return array('id' => $id, 'data' => array(':new:' => array(), ':old:' => array()));
 }
Ejemplo n.º 4
0
 /**
  * Test the Auth::logout method.
  *
  * @group laravel
  */
 public function testLogoutMethodLogsOutUser()
 {
     Session::$instance = new Payload($this->getMock('Laravel\\Session\\Drivers\\Driver'));
     $data = Session::$instance->session['data']['laravel_auth_drivers_fluent_login'] = 1;
     Auth::logout();
     $this->assertNull(Auth::user());
     $this->assertFalse(isset(Session::$instance->session['data']['laravel_auth_drivers_fluent_login']));
     $this->assertTrue(Cookie::$jar['laravel_auth_drivers_fluent_remember']['expiration'] < time());
 }
Ejemplo n.º 5
0
 /**
  * Test `laravel.auth: login` and `laravel.auth: logout` is called properly
  *
  * @group laravel
  */
 public function testAuthEventIsCalledProperly()
 {
     Session::$instance = new Payload($this->getMock('Laravel\\Session\\Drivers\\Driver'));
     Event::listen('laravel.auth: login', function () {
         $_SERVER['test.user.login'] = '******';
     });
     Event::listen('laravel.auth: logout', function () {
         $_SERVER['test.user.logout'] = 'foo';
     });
     $this->assertNull($_SERVER['test.user.login']);
     $this->assertNull($_SERVER['test.user.logout']);
     Auth::login(1, true);
     $this->assertEquals('foo', $_SERVER['test.user.login']);
     Auth::logout();
     $this->assertEquals('foo', $_SERVER['test.user.logout']);
 }