public function testValidation()
 {
     $field = new ConfirmedPasswordField('Test', 'Testing', array("_Password" => "abc123", "_ConfirmPassword" => "abc123"));
     $validator = new RequiredFields();
     /** @skipUpgrade */
     $form = new Form($this, 'Form', new FieldList($field), new FieldList(), $validator);
     $this->assertTrue($field->validate($validator), "Validates when both passwords are the same");
     $field->setName("TestNew");
     //try changing name of field
     $this->assertTrue($field->validate($validator), "Validates when field name is changed");
     //non-matching password should make the field invalid
     $field->setValue(array("_Password" => "abc123", "_ConfirmPassword" => "123abc"));
     $this->assertFalse($field->validate($validator), "Does not validate when passwords differ");
 }
 /**
  * Builds "Change / Create Password" field for this member
  *
  * @return ConfirmedPasswordField
  */
 public function getMemberPasswordField()
 {
     $editingPassword = $this->isInDB();
     $label = $editingPassword ? _t('Member.EDIT_PASSWORD', 'New Password') : $this->fieldLabel('Password');
     /** @var ConfirmedPasswordField $password */
     $password = ConfirmedPasswordField::create('Password', $label, null, null, $editingPassword);
     // If editing own password, require confirmation of existing
     if ($editingPassword && $this->ID == Member::currentUserID()) {
         $password->setRequireExistingPassword(true);
     }
     $password->setCanBeEmpty(true);
     $this->extend('updateMemberPasswordField', $password);
     return $password;
 }