示例#1
0
 public function testLogAuditEventChangingUsersPassword()
 {
     Yii::app()->user->userModel = User::getByUsername('jimmy');
     $beforeCount = AuditEvent::getCount();
     $user = new User();
     $user->username = '******';
     $user->firstName = 'Ed';
     $user->lastName = 'Gein';
     $this->assertTrue($user->save());
     $this->assertEquals($beforeCount + 2, AuditEvent::getCount());
     $user->setPassword('waggles');
     $this->assertTrue($user->save());
     $this->assertEquals($beforeCount + 3, AuditEvent::getCount());
     $user->setPassword('bibbler');
     $this->assertTrue($user->save());
     $this->assertEquals($beforeCount + 4, AuditEvent::getCount());
     $AuditEventsList = AuditEvent::getTailEvents(2);
     $this->assertRegExp('/[0-9]+\\/[0-9]+\\/[0-9]+ [0-9]+:[0-9]+ [AP]M, ' . 'James Boondog, User Password Changed/', UsersModule::stringifyAuditEvent($AuditEventsList[0]));
     $this->assertRegExp('/[0-9]+\\/[0-9]+\\/[0-9]+ [0-9]+:[0-9]+ [AP]M, ' . 'James Boondog, User Password Changed/', UsersModule::stringifyAuditEvent($AuditEventsList[0]));
 }