public function testPasswordReset() { $fakeIdentity = new UserIdentity(null, null); $fakeIdentity->setId(999); $this->assertFalse($fakeIdentity->resetPassword('xx')); $identity = UserIdentity::find(array('username' => 'cat')); $this->assertEquals(4, $identity->getId()); $this->assertFalse($identity->authenticate()); $dateBefore = date('Y-m-d H:i:s'); $this->assertTrue($identity->resetPassword('Test1234')); $dateAfter = date('Y-m-d H:i:s'); $identity->password = '******'; $this->assertTrue($identity->authenticate()); $this->assertGreaterThanOrEqual($dateBefore, $identity->getPasswordDate()); $this->assertLessThanOrEqual($dateAfter, $identity->getPasswordDate()); $this->assertGreaterThanOrEqual($dateBefore, $identity->getPasswordDate('Test1234')); $this->assertLessThanOrEqual($dateAfter, $identity->getPasswordDate('Test1234')); $this->assertNull($identity->getPasswordDate('xx')); }