public function testValidation() { $field = new ConfirmedPasswordField('Test', 'Testing', array("_Password" => "abc123", "_ConfirmPassword" => "abc123")); $validator = new RequiredFields(); $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"); }