Просмотр исходного кода

[ZF-9201] Zend_Validate:

- fixed MX to work without deep check (thnx to Michael)

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@21082 44c647ce-9c0f-0410-b52a-842ac1e357ba
thomas 16 лет назад
Родитель
Сommit
5dd2ee05df

+ 2 - 3
library/Zend/Validate/EmailAddress.php

@@ -441,10 +441,9 @@ class Zend_Validate_EmailAddress extends Zend_Validate_Abstract
      */
     private function _validateMXRecords()
     {
-        $result = true;
         $mxHosts = array();
-        getmxrr($this->_hostname, $mxHosts);
-        if ($this->_options['deep'] && function_exists('checkdnsrr')) {
+        $result = getmxrr($this->_hostname, $mxHosts);
+        if ($result && $this->_options['deep'] && function_exists('checkdnsrr')) {
             $validAddress = false;
             $reserved     = true;
             foreach ($mxHosts as $hostname) {

+ 4 - 3
tests/Zend/Validate/EmailAddressTest.php

@@ -319,12 +319,13 @@ class Zend_Validate_EmailAddressTest extends PHPUnit_Framework_TestCase
 
         // Are MX checks supported by this system?
         if (!$validator->validateMxSupported()) {
-            return true;
+            $this->markTestSkipped('Testing MX records is not supported with this configuration');
+            return;
         }
 
         $valuesExpected = array(
-            array(true, array('Bob.Jones@zend.com', 'Bob.Jones@studio24.net')),
-            array(false, array('Bob.Jones@madeupdomain242424a.com', 'Bob.Jones@madeupdomain242424b.net'))
+            array(true, array('Bob.Jones@zend.com', 'Bob.Jones@php.net')),
+            array(false, array('Bob.Jones@bad.example.com', 'Bob.Jones@anotherbad.example.com'))
             );
         foreach ($valuesExpected as $element) {
             foreach ($element[1] as $input) {