Beispiel #1
0
 public function testEmails()
 {
     $xml = simplexml_load_file(__DIR__ . '/emails.xml', 'SimpleXMLElement', LIBXML_NONET);
     foreach ($xml->t as $test) {
         $email = (string) $test->a;
         $res = (string) $test->r == 't';
         try {
             $w = validator\Net::email($email, array('allow_comments' => true, 'public_internet' => false));
         } catch (Invalid $e) {
             if (!$res) {
                 continue;
             }
             $this->fail(sprintf('This value should be good: %s.', $email));
         }
         if (!$res) {
             $this->fail(sprintf('This value should be bad: %s.', $email));
         }
     }
 }
Beispiel #2
0
 public function __construct($params = array())
 {
     parent::__construct($params);
     $this->validators[] = function ($value) {
         return validator\Net::email($value);
     };
 }