mirror of
https://github.com/egulias/EmailValidator.git
synced 2026-09-11 02:26:36 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 518f80a0ff | |||
| 2ec7babda6 | |||
| 05367768d6 |
@@ -84,7 +84,7 @@ class EmailValidator
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$dns = false;
|
$dns = true;
|
||||||
if ($checkDNS) {
|
if ($checkDNS) {
|
||||||
$dns = $this->checkDNS();
|
$dns = $this->checkDNS();
|
||||||
}
|
}
|
||||||
@@ -95,12 +95,7 @@ class EmailValidator
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ($strict) ? $this->checkStrict($dns) : true;
|
return !$strict || (!$this->hasWarnings() && $dns);
|
||||||
}
|
|
||||||
|
|
||||||
private function checkStrict($dns)
|
|
||||||
{
|
|
||||||
return !($this->hasWarnings() && !$dns);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -150,6 +150,16 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals($warnings, $this->validator->getWarnings());
|
$this->assertEquals($warnings, $this->validator->getWarnings());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider getInvalidEmailsWithWarnings
|
||||||
|
*/
|
||||||
|
public function testInvalidEmailsWithDnsCheckAndStrictMode($warnings, $email)
|
||||||
|
{
|
||||||
|
$this->assertFalse($this->validator->isValid($email, true, true));
|
||||||
|
|
||||||
|
$this->assertEquals($warnings, $this->validator->getWarnings());
|
||||||
|
}
|
||||||
|
|
||||||
public function getInvalidEmailsWithWarnings()
|
public function getInvalidEmailsWithWarnings()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
@@ -301,14 +311,15 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'parttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalpart'.
|
'parttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalpart'.
|
||||||
'toolonglocalparttoolonglocalparttoolonglocalparttoolonglocalpar'
|
'toolonglocalparttoolonglocalparttoolonglocalparttoolonglocalpar'
|
||||||
),
|
),
|
||||||
|
array(
|
||||||
|
array(
|
||||||
|
EmailValidator::DNSWARN_NO_RECORD,
|
||||||
|
),
|
||||||
|
'test@test'
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testInvalidEmailsWithDNSAndStrict()
|
|
||||||
{
|
|
||||||
$this->assertFalse($this->validator->isValid('test@test', true, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testInvalidEmailsWithStrict()
|
public function testInvalidEmailsWithStrict()
|
||||||
{
|
{
|
||||||
$this->assertFalse($this->validator->isValid('"test"@test', false, true));
|
$this->assertFalse($this->validator->isValid('"test"@test', false, true));
|
||||||
|
|||||||
Reference in New Issue
Block a user