Beispiel #1
0
 public function testRecord()
 {
     $fakeIdentity = new UserIdentity(null, null);
     $fakeIdentity->setId(999);
     $this->assertFalse($fakeIdentity->isDisabled());
     $this->assertFalse($fakeIdentity->isActive());
     $identity = new UserIdentity('neo', 'xxx');
     $this->assertFalse($identity->authenticate());
     $this->assertFalse($identity->getIsAuthenticated());
     $identity = new UserIdentity('tank', 'Test1233');
     $this->assertFalse($identity->authenticate());
     $this->assertFalse($identity->getIsAuthenticated());
     $identity = new UserIdentity('neo', 'Test1233');
     $this->assertTrue($identity->authenticate());
     $this->assertTrue($identity->getIsAuthenticated());
     $this->assertTrue($identity->isActive());
     $this->assertFalse($identity->isDisabled());
     $this->assertEquals('2011-11-11 12:34', $identity->getPasswordDate());
     $this->assertEquals('2011-11-11 12:34', $identity->getPasswordDate('Test1233'));
     $this->assertNull($identity->getPasswordDate('xxx'));
     $identity2 = UserIdentity::find(array('username' => 'neo'));
     $this->assertEquals($identity->getId(), $identity2->getId());
     $identity3 = UserIdentity::find(array('username' => 'tank'));
     $this->assertEquals(2, $identity3->getId());
     $this->assertFalse($identity3->isActive());
     $this->assertTrue($identity3->isDisabled());
 }