Ejemplo n.º 1
0
 public function testAuthPersist()
 {
     Auth::reset();
     Auth::config(array('test' => array('adapter' => $this->_classes['mockAuthAdapter'])));
     $config = Auth::config();
     $this->assertTrue(isset($config['test']['session']['persist']));
     $this->assertTrue(empty($config['test']['session']['persist']));
     $user = array('username' => 'foo', 'password' => 'bar');
     $result = Auth::check('test', $user, array('success' => true));
     $this->assertTrue(isset($result['username']));
     $this->assertFalse(isset($result['password']));
     Auth::reset();
     Auth::config(array('test' => array('adapter' => $this->_classes['mockAuthAdapter'], 'session' => array('persist' => array('username', 'email')))));
     $user = array('username' => 'foobar', 'password' => 'not!important', 'email' => '*****@*****.**', 'insuranceNumer' => 1234567);
     $expected = array('username' => 'foobar', 'email' => '*****@*****.**');
     $result = Auth::check('test', $user, array('success' => true, 'checkSession' => false));
     $this->assertEqual($expected, $result);
     $this->assertEqual($expected, Session::read('test'));
     Auth::reset();
     Auth::config(array('test' => array('adapter' => $this->_classes['mockAuthAdapter'])));
     $user = array('id' => '123', 'username' => 'foobar', 'password' => 'not!important', 'email' => '*****@*****.**', 'insuranceNumer' => 1234567);
     $expected = 123;
     $result = Auth::check('test', $user, array('keyOnly' => true, 'checkSession' => false));
     $this->assertEqual($expected, $result);
     $this->assertEqual($expected, Session::read('test'));
 }
Ejemplo n.º 2
0
 public function testNoConfigurations()
 {
     Auth::reset();
     $this->assertIdentical(array(), Auth::config());
     $this->expectException("Configuration `user` has not been defined.");
     Auth::check('user');
 }