示例#1
0
 /**
  * Ensures that the validator follows expected behavior for checking MX records
  *
  * @return void
  */
 public function testMXRecords()
 {
     if (!defined('TESTS_ZEND_VALIDATE_ONLINE_ENABLED') || !constant('TESTS_ZEND_VALIDATE_ONLINE_ENABLED')) {
         $this->markTestSkipped('Testing MX records has been disabled');
         return;
     }
     $validator = new Validator\EmailAddress(Hostname::ALLOW_DNS, true);
     // Are MX checks supported by this system?
     if (!$validator->isMxSupported()) {
         $this->markTestSkipped('Testing MX records is not supported with this configuration');
         return;
     }
     $valuesExpected = array(array(true, array('*****@*****.**', '*****@*****.**')), array(false, array('*****@*****.**', '*****@*****.**')));
     foreach ($valuesExpected as $element) {
         foreach ($element[1] as $input) {
             $this->assertEquals($element[0], $validator->isValid($input), implode("\n", $validator->getMessages()));
         }
     }
     // Try a check via setting the option via a method
     unset($validator);
     $validator = new Validator\EmailAddress();
     $validator->useMxCheck(true);
     foreach ($valuesExpected as $element) {
         foreach ($element[1] as $input) {
             $this->assertEquals($element[0], $validator->isValid($input), implode("\n", $validator->getMessages()));
         }
     }
 }