Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Validator] add domain test for windows check dns #27559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Symfony/Component/Validator/Constraints/EmailValidator.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ public function validate($value, Constraint $constraint)

$host = (string) substr($value, strrpos($value, '@') + 1);

if ('.' !== substr($host, -1)) {
$host .= '.';
}

// Check for host DNS resource records
if ($constraint->checkMX) {
if (!$this->checkMX($host)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,20 +114,20 @@ public function testStrict()
*/
public function testDnsChecks($type, $violation)
{
DnsMock::withMockedHosts(array('example.com' => array(array('type' => $violation ? false : $type))));
DnsMock::withMockedHosts(array('another-example.com' => array(array('type' => $violation ? false : $type))));

$constraint = new Email(array(
'message' => 'myMessage',
'MX' === $type ? 'checkMX' : 'checkHost' => true,
));

$this->validator->validate('[email protected]', $constraint);
$this->validator->validate('foo@another-example.com', $constraint);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

example.com.com is valid but test want violation. I continue to investigate


if (!$violation) {
$this->assertNoViolation();
} else {
$this->buildViolation('myMessage')
->setParameter('{{ value }}', '"[email protected]"')
->setParameter('{{ value }}', '"foo@another-example.com"')
->setCode($violation)
->assertRaised();
}
Expand Down