Skip to content

Commit d0201d1

Browse files
apetitpafabpot
authored andcommitted
Add a test to prevent future regressions
1 parent 24d8121 commit d0201d1

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Tests/Constraints/EmailValidatorTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,32 @@ public function testHostnameIsProperlyParsed()
159159

160160
$this->assertNoViolation();
161161
}
162+
163+
public function getCheckTypes()
164+
{
165+
return array(
166+
array('checkMX', Email::MX_CHECK_FAILED_ERROR),
167+
array('checkHost', Email::HOST_CHECK_FAILED_ERROR),
168+
);
169+
}
170+
171+
/**
172+
* @dataProvider getCheckTypes
173+
*/
174+
public function testEmptyHostIsNotValid($checkType, $violation)
175+
{
176+
$this->validator->validate(
177+
'foo@bar.fr@',
178+
new Email(array(
179+
'message' => 'myMessage',
180+
$checkType => true,
181+
))
182+
);
183+
184+
$this
185+
->buildViolation('myMessage')
186+
->setParameter('{{ value }}', '"foo@bar.fr@"')
187+
->setCode($violation)
188+
->assertRaised();
189+
}
162190
}

0 commit comments

Comments
 (0)