Skip to content
Extraits de code Groupes Projets
Valider 4aee468d rédigé par mattab's avatar mattab
Parcourir les fichiers

only fail when at least 5 domains extensions are failing, so it does not fail...

only fail when at least 5 domains extensions are failing, so it does not fail every time IANA adds a new domain extension...
parent 1266ba27
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -34,6 +34,8 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase ...@@ -34,6 +34,8 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase
unset($tlds[$key]); unset($tlds[$key]);
} }
} }
$minimumTlds = 1200;
$this->assertGreaterThan( $minimumTlds, count($tlds), "expected to download at least $minimumTlds domain names");
return $tlds; return $tlds;
} }
...@@ -44,8 +46,8 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase ...@@ -44,8 +46,8 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase
} }
} }
public function test_allCurrentTlds(){ public function test_allCurrentTlds()
{
$this->skipTestIfIdnNotAvailable(); $this->skipTestIfIdnNotAvailable();
$tlds = $this->getAllTlds(); $tlds = $this->getAllTlds();
...@@ -53,19 +55,27 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase ...@@ -53,19 +55,27 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase
$this->markTestSkipped("Couldn't get TLD list"); $this->markTestSkipped("Couldn't get TLD list");
} }
$errors = array();
foreach ($tlds as $key => $tld) { foreach ($tlds as $key => $tld) {
if (strpos(mb_strtolower($tld), 'xn--') !== 0) { if (strpos(mb_strtolower($tld), 'xn--') !== 0) {
$tld = mb_strtolower($tld); $tld = mb_strtolower($tld);
} }
$email = 'test@example.' . idn_to_utf8($tld); $domainNameExtension = idn_to_utf8($tld);
$this->assertTrue( $email = 'test@example.' . $domainNameExtension;
$this->isValid($email),
"email $email is not valid, but expected to be valid. Add this domain extension to libs/Zend/Validate/Hostname.php" if(!$this->isValid($email)) {
); $errors[] = "email $email is not valid, but expected to be valid. Add this domain extension to libs/Zend/Validate/Hostname.php";
}
}
// only fail when at least 5 domains are failing the test, so it does not fail every time IANA adds a new domain extension...
if(count($errors) > 5) {
$this->fail( implode(", ", $errors));
} }
} }
public function test_invalidTld(){ public function test_invalidTld()
{
$this->skipTestIfIdnNotAvailable(); $this->skipTestIfIdnNotAvailable();
$tlds = [ $tlds = [
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter