From 7ca14d216ea95cbce881867a4cb953b367fb7d85 Mon Sep 17 00:00:00 2001 From: mattab <matthieu.aubry@gmail.com> Date: Tue, 23 Aug 2016 09:22:53 +1200 Subject: [PATCH] Fix the integration test and patch Zend Validate --- libs/Zend/Validate/Hostname.php | 6 ++++++ tests/PHPUnit/Integration/EmailValidatorTest.php | 15 ++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/libs/Zend/Validate/Hostname.php b/libs/Zend/Validate/Hostname.php index 79e9902b6e..1ea9800546 100644 --- a/libs/Zend/Validate/Hostname.php +++ b/libs/Zend/Validate/Hostname.php @@ -492,6 +492,12 @@ class Zend_Validate_Hostname extends Zend_Validate_Abstract '微博' => array(1 => self::VALID_UNICODE_DOMAIN), 'ابوظبي' => array(1 => self::VALID_UNICODE_DOMAIN), '网站' => array(1 => self::VALID_UNICODE_DOMAIN), + '大众汽车' => array(1 => self::VALID_UNICODE_DOMAIN), + '香格里拉' => array(1 => self::VALID_UNICODE_DOMAIN), + 'бг' => array(1 => self::VALID_UNICODE_DOMAIN), + '電訊盈科' => array(1 => self::VALID_UNICODE_DOMAIN), + 'العليان' => array(1 => self::VALID_UNICODE_DOMAIN), + '嘉里' => array(1 => self::VALID_UNICODE_DOMAIN), ); diff --git a/tests/PHPUnit/Integration/EmailValidatorTest.php b/tests/PHPUnit/Integration/EmailValidatorTest.php index 75b37e5a60..a9adff114a 100644 --- a/tests/PHPUnit/Integration/EmailValidatorTest.php +++ b/tests/PHPUnit/Integration/EmailValidatorTest.php @@ -42,7 +42,7 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase private function skipTestIfIdnNotAvailable() { if (!function_exists('idn_to_utf8')) { - $this->markTestSkipped("Couldn't get TLD list"); + $this->markTestSkipped("Function idn_to_utf8 does not exist, skip test"); } } @@ -64,13 +64,18 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase $email = 'test@example.' . $domainNameExtension; 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"; + $errors[] = $domainNameExtension; } } - // 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)); + // only fail when at least 10 domains are failing the test, so it does not fail every time IANA adds a new domain extension... + if(count($errors) > 5) + { + $out = ''; + foreach($errors as $domainNameExtension) { + $out .= "\t'$domainNameExtension' => array(1 => self::VALID_UNICODE_DOMAIN),\n"; + } + $this->fail( "Some email extensions are not supported yet, you can add these domain extensions in libs/Zend/Validate/Hostname.php: \n\n" . $out); } } -- GitLab