Add a test to prevent future regressions

This commit is contained in:
apetitpa 2017-03-24 17:17:11 +01:00 committed by Fabien Potencier
parent 6f24b05467
commit d973eb1f7d
1 changed files with 28 additions and 0 deletions

View File

@ -159,4 +159,32 @@ class EmailValidatorTest extends AbstractConstraintValidatorTest
$this->assertNoViolation();
}
public function getCheckTypes()
{
return array(
array('checkMX', Email::MX_CHECK_FAILED_ERROR),
array('checkHost', Email::HOST_CHECK_FAILED_ERROR),
);
}
/**
* @dataProvider getCheckTypes
*/
public function testEmptyHostIsNotValid($checkType, $violation)
{
$this->validator->validate(
'foo@bar.fr@',
new Email(array(
'message' => 'myMessage',
$checkType => true,
))
);
$this
->buildViolation('myMessage')
->setParameter('{{ value }}', '"foo@bar.fr@"')
->setCode($violation)
->assertRaised();
}
}