fixed DNSCheckValidation bug (#115)

This commit is contained in:
Issei.M
2016-06-22 00:31:36 +09:00
committed by Eduardo Gulias Davis
parent e9c46eed92
commit afde3d3874
2 changed files with 14 additions and 3 deletions
@@ -28,7 +28,7 @@ class DNSCheckValidation implements EmailValidation
// use the input to check DNS if we cannot extract something similar to a domain
$host = $email;
// Arguable pattern to extract the domain. Not aiming to validate the domain nor the email
$pattern = "/^[a-z'0-9]+([._-][a-z'0-9]+)*@([a-z0-9]+([._-][a-z0-9]+)+)+$/";
$pattern = "/^[a-z'0-9]+([+._-][a-z'0-9]+)*@([a-z0-9]+([._-][a-z0-9]+)+)+$/";
if (preg_match($pattern, $email, $result)) {
$host = $this->extractHost($result);
}
@@ -9,10 +9,21 @@ use Egulias\EmailValidator\Warning\NoDNSMXRecord;
class DNSCheckValidationTest extends \PHPUnit_Framework_TestCase
{
public function testValidDNS()
public function validEmailsProvider()
{
return [
["example@example.com"],
["example+foo@example.com"],
];
}
/**
* @dataProvider validEmailsProvider
*/
public function testValidDNS($validEmail)
{
$validation = new DNSCheckValidation();
$this->assertTrue($validation->isValid("example@example.com", new EmailLexer()));
$this->assertTrue($validation->isValid($validEmail, new EmailLexer()));
}
public function testInvalidDNS()