lithium\tests\cases\security\AuthTest::testAuthPersist PHP Method

testAuthPersist() public method

public testAuthPersist ( )
    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' => '[email protected]', 'insuranceNumer' => 1234567);
        $expected = array('username' => 'foobar', 'email' => '[email protected]');
        $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' => '[email protected]', 'insuranceNumer' => 1234567);
        $expected = 123;
        $result = Auth::check('test', $user, array('keyOnly' => true, 'checkSession' => false));
        $this->assertEqual($expected, $result);
        $this->assertEqual($expected, Session::read('test'));
    }