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