Ejemplo n.º 1
0
 public function testUserEmailChange()
 {
     $newEmail = '*****@*****.**';
     $model = $this->user;
     $profileForm = new ProfileForm();
     $this->assertTrue($model !== NULL);
     $profileForm->load($model->id, true);
     $profileForm->email = $newEmail;
     // Verify that the profile form saves
     $this->assertTrue($profileForm->save());
     // Verify that the base user model didn't change
     $model = $this->getUserModel();
     $this->assertTrue($model->email == '*****@*****.**');
     $newEmailModel = UserMetadata::model()->findByAttributes(array('user_id' => $this->user->id, 'key' => 'newEmailAddress'));
     // Verify that the new email is stored in the database
     $this->assertTrue($newEmailModel !== NULL);
     $this->assertTrue($newEmailModel->value == $newEmail);
     $key = UserMetadata::model()->findByAttributes(array('user_id' => $this->user->id, 'key' => 'newEmailAddressChangeKey'));
     $this->assertTrue($key !== NULL);
     $emailChangeForm = new EmailChangeForm();
     $emailChangeForm->setUser($this->getUserModel());
     $emailChangeForm->verificationKey = $key->value;
     $emailChangeForm->password = '******';
     // Verify that the verification key works
     $this->assertTrue($emailChangeForm->validateVerificationKey());
     // Veirfy that the email address changes
     $this->assertTrue($emailChangeForm->validate());
     $this->assertTrue($emailChangeForm->save());
     // Verify that the email has changed for the model now
     $model = Users::model()->findByAttributes(array('email' => '*****@*****.**'));
     $this->assertTrue($model->email == $newEmail);
 }