Example #1
0
 function testParseEmailAddresses()
 {
     $tests = \Symfony\Component\Yaml\Yaml::parse(file_get_contents(__DIR__ . "/testspec.yml"));
     foreach ($tests as $test) {
         $emails = $test['emails'];
         $multiple = $test['multiple'];
         $result = $test['result'];
         $this->assertSame($result, Parse::getInstance()->parse($emails, $multiple));
     }
 }
Example #2
0
 function testParseEmailAddresses()
 {
     $emails = "*****@*****.**";
     $result = serialize(Parse::getInstance()->parse($emails));
     $this->assertEquals('a:3:{s:7:"success";b:1;s:6:"reason";N;s:15:"email_addresses";a:1:{i:0;a:12:{s:7:"address";s:21:"*****@*****.**";s:14:"simple_address";s:21:"*****@*****.**";s:16:"original_address";s:21:"*****@*****.**";s:4:"name";s:0:"";s:11:"name_parsed";s:0:"";s:10:"local_part";s:6:"t.name";s:17:"local_part_parsed";s:6:"t.name";s:11:"domain_part";s:14:"asdf.ghjkl.com";s:6:"domain";s:14:"asdf.ghjkl.com";s:2:"ip";s:0:"";s:7:"invalid";b:0;s:14:"invalid_reason";N;}}}', $result);
     $emails = "*****@*****.**";
     $result = serialize(Parse::getInstance()->parse($emails));
     $this->assertEquals('a:3:{s:7:"success";b:1;s:6:"reason";N;s:15:"email_addresses";a:1:{i:0;a:12:{s:7:"address";s:20:"*****@*****.**";s:14:"simple_address";s:20:"*****@*****.**";s:16:"original_address";s:20:"*****@*****.**";s:4:"name";s:0:"";s:11:"name_parsed";s:0:"";s:10:"local_part";s:5:"tname";s:17:"local_part_parsed";s:5:"tname";s:11:"domain_part";s:14:"asdf.ghjkl.com";s:6:"domain";s:14:"asdf.ghjkl.com";s:2:"ip";s:0:"";s:7:"invalid";b:0;s:14:"invalid_reason";N;}}}', $result);
     // Test as single address
     $result = serialize(Parse::getInstance()->parse($emails, false));
     $this->assertEquals('a:12:{s:7:"address";s:20:"*****@*****.**";s:14:"simple_address";s:20:"*****@*****.**";s:16:"original_address";s:20:"*****@*****.**";s:4:"name";s:0:"";s:11:"name_parsed";s:0:"";s:10:"local_part";s:5:"tname";s:17:"local_part_parsed";s:5:"tname";s:11:"domain_part";s:14:"asdf.ghjkl.com";s:6:"domain";s:14:"asdf.ghjkl.com";s:2:"ip";s:0:"";s:7:"invalid";b:0;s:14:"invalid_reason";N;}', $result);
     $emails = "Testing Name <*****@*****.**>";
     $result = serialize(Parse::getInstance()->parse($emails));
     $this->assertEquals('a:3:{s:7:"success";b:1;s:6:"reason";N;s:15:"email_addresses";a:1:{i:0;a:12:{s:7:"address";s:35:"Testing Name <*****@*****.**>";s:14:"simple_address";s:20:"*****@*****.**";s:16:"original_address";s:35:"Testing Name <*****@*****.**>";s:4:"name";s:12:"Testing Name";s:11:"name_parsed";s:12:"Testing Name";s:10:"local_part";s:5:"tname";s:17:"local_part_parsed";s:5:"tname";s:11:"domain_part";s:14:"asdf.ghjkl.com";s:6:"domain";s:14:"asdf.ghjkl.com";s:2:"ip";s:0:"";s:7:"invalid";b:0;s:14:"invalid_reason";N;}}}', $result);
     // Test as single address
     $result = serialize(Parse::getInstance()->parse($emails, false));
     $this->assertEquals('a:12:{s:7:"address";s:35:"Testing Name <*****@*****.**>";s:14:"simple_address";s:20:"*****@*****.**";s:16:"original_address";s:35:"Testing Name <*****@*****.**>";s:4:"name";s:12:"Testing Name";s:11:"name_parsed";s:12:"Testing Name";s:10:"local_part";s:5:"tname";s:17:"local_part_parsed";s:5:"tname";s:11:"domain_part";s:14:"asdf.ghjkl.com";s:6:"domain";s:14:"asdf.ghjkl.com";s:2:"ip";s:0:"";s:7:"invalid";b:0;s:14:"invalid_reason";N;}', $result);
     $emails = "Testing D Name <*****@*****.**>";
     $result = serialize(Parse::getInstance()->parse($emails));
     $this->assertEquals('a:3:{s:7:"success";b:1;s:6:"reason";N;s:15:"email_addresses";a:1:{i:0;a:12:{s:7:"address";s:37:"Testing D Name <*****@*****.**>";s:14:"simple_address";s:20:"*****@*****.**";s:16:"original_address";s:37:"Testing D Name <*****@*****.**>";s:4:"name";s:14:"Testing D Name";s:11:"name_parsed";s:14:"Testing D Name";s:10:"local_part";s:5:"tname";s:17:"local_part_parsed";s:5:"tname";s:11:"domain_part";s:14:"asdf.ghjkl.com";s:6:"domain";s:14:"asdf.ghjkl.com";s:2:"ip";s:0:"";s:7:"invalid";b:0;s:14:"invalid_reason";N;}}}', $result);
     // Test as single address
     $result = serialize(Parse::getInstance()->parse($emails, false));
     $this->assertEquals('a:12:{s:7:"address";s:37:"Testing D Name <*****@*****.**>";s:14:"simple_address";s:20:"*****@*****.**";s:16:"original_address";s:37:"Testing D Name <*****@*****.**>";s:4:"name";s:14:"Testing D Name";s:11:"name_parsed";s:14:"Testing D Name";s:10:"local_part";s:5:"tname";s:17:"local_part_parsed";s:5:"tname";s:11:"domain_part";s:14:"asdf.ghjkl.com";s:6:"domain";s:14:"asdf.ghjkl.com";s:2:"ip";s:0:"";s:7:"invalid";b:0;s:14:"invalid_reason";N;}', $result);
     $emails = "Testing D. Name  <*****@*****.**>";
     $result = serialize(Parse::getInstance()->parse($emails));
     $this->assertEquals('a:3:{s:7:"success";b:0;s:6:"reason";s:21:"Invalid email address";s:15:"email_addresses";a:2:{i:0;a:12:{s:7:"address";s:0:"";s:14:"simple_address";s:0:"";s:16:"original_address";s:15:"Testing D. Name";s:4:"name";s:10:"Testing D.";s:11:"name_parsed";s:10:"Testing D.";s:10:"local_part";s:0:"";s:17:"local_part_parsed";s:0:"";s:11:"domain_part";s:0:"";s:6:"domain";s:0:"";s:2:"ip";s:0:"";s:7:"invalid";b:1;s:14:"invalid_reason";s:110:"Periods within the name of an email address must appear in quotes, such as "John Q. Public" <*****@*****.**>";}i:1;a:12:{s:7:"address";s:20:"*****@*****.**";s:14:"simple_address";s:20:"*****@*****.**";s:16:"original_address";s:22:"<*****@*****.**>";s:4:"name";s:0:"";s:11:"name_parsed";s:0:"";s:10:"local_part";s:5:"tname";s:17:"local_part_parsed";s:5:"tname";s:11:"domain_part";s:14:"asdf.ghjkl.com";s:6:"domain";s:14:"asdf.ghjkl.com";s:2:"ip";s:0:"";s:7:"invalid";b:0;s:14:"invalid_reason";N;}}}', $result);
     // Test as single address
     $result = serialize(Parse::getInstance()->parse($emails, false));
     $this->assertEquals('a:12:{s:7:"address";s:0:"";s:14:"simple_address";s:0:"";s:16:"original_address";s:39:"Testing D. Name  <*****@*****.**>";s:4:"name";s:10:"Testing D.";s:11:"name_parsed";s:10:"Testing D.";s:10:"local_part";s:0:"";s:17:"local_part_parsed";s:0:"";s:11:"domain_part";s:0:"";s:6:"domain";s:0:"";s:2:"ip";s:0:"";s:7:"invalid";b:1;s:14:"invalid_reason";s:110:"Periods within the name of an email address must appear in quotes, such as "John Q. Public" <*****@*****.**>";}', $result);
     $emails = "test.testing@asdf.ghjkl.com test.testing2@asdf.ghjkl.com";
     $result = json_encode(Parse::getInstance()->parse($emails));
     $this->assertEquals('{"success":true,"reason":null,"email_addresses":[{"address":"*****@*****.**","simple_address":"*****@*****.**","original_address":"*****@*****.**","name":"","name_parsed":"","local_part":"test.testing","local_part_parsed":"test.testing","domain_part":"asdf.ghjkl.com","domain":"asdf.ghjkl.com","ip":"","invalid":false,"invalid_reason":null},{"address":"*****@*****.**","simple_address":"*****@*****.**","original_address":"*****@*****.**","name":"","name_parsed":"","local_part":"test.testing2","local_part_parsed":"test.testing2","domain_part":"asdf.ghjkl.com","domain":"asdf.ghjkl.com","ip":"","invalid":false,"invalid_reason":null}]}', $result);
     $emails = array("\"Testing D. Name\" <*****@*****.**>", "<*****@*****.**>", "<*****@*****.**>", "\"test .s set .set\"@asdf.ghjkl.com", "<*****@*****.**>", "<*****@*****.**>", "tname@asdf.ghjkl.com, tname@asdf.ghjkl.com, tname-test1@asdf.ghjkl.com", "tnam e@asdf.g asdfa hjkl.com, tn'''ame@asdf.ghjkl.com, tname-test1@asdf.ghjkl.com", "Testing D Name <*****@*****.**> tname@asdf.ghjkl.com tname-test1@asdf.ghjkl.com", "Testing D Name <*****@*****.**> (comment) tn(comment1)ame@asdf.gh(comment2)jkl.com tname-test1(comment3)@asdf.ghjkl.com", "Tes!@#\$@\$&*&%(*ti)ng D Name <*****@*****.**> (comment) tna(m!@#(\$(!(^)\$)#)!^%#&*%^#)mment1e@asdf.gh(comment2)jkl.com tname-test1(comment3)@asdf.ghjkl.com", "tname@[10.0.10.45] tname@asdf.ghjkl.com, tname-test2@asdf.ghjkl.com", "t\"na\"me@[10.0.10.45] tname@asdf.ghjkl.com, tname-test2@asdf.ghjkl.com", "t(comment with spaces !!!)name@[10.0.10.45] tname@asdf.ghjkl.com, tname-test2@asdf.ghjkl.com", "testing@tūdaliņ.lv", "*****@*****.**", "*****@*****.**", "testing@192.168.0.1", "testing@256.26.52.5", "testing@[256.26.52.5]", "testing@[299.236.532.265]", "testing@[80.67.66.65]", "testing@80.67.66.65");
     $results1 = array('{"success":true,"reason":null,"email_addresses":[{"address":"\\"Testing D. Name\\" <*****@*****.**>","simple_address":"*****@*****.**","original_address":"\\"Testing D. Name\\" <*****@*****.**>","name":"\\"Testing D. Name\\"","name_parsed":"Testing D. Name","local_part":"tname","local_part_parsed":"tname","domain_part":"asdf.ghjkl.com","domain":"asdf.ghjkl.com","ip":"","invalid":false,"invalid_reason":null}]}', '{"success":true,"reason":null,"email_addresses":[{"address":"*****@*****.**","simple_address":"*****@*****.**","original_address":"<*****@*****.**>","name":"","name_parsed":"","local_part":"tname","local_part_parsed":"tname","domain_part":"asdf.ghjkl.com","domain":"asdf.ghjkl.com","ip":"","invalid":false,"invalid_reason":null}]}', '{"success":false,"reason":"Invalid email address","email_addresses":[{"address":"","simple_address":"","original_address":"<*****@*****.**>","name":"","name_parsed":"","local_part":"","local_part_parsed":"","domain_part":"","domain":"","ip":"","invalid":true,"invalid_reason":"Email address can not start with \'.\'"}]}', '{"success":true,"reason":null,"email_addresses":[{"address":"\\"test .s set .set\\"@asdf.ghjkl.com","simple_address":"\\"test .s set .set\\"@asdf.ghjkl.com","original_address":"\\"test .s set .set\\"@asdf.ghjkl.com","name":"","name_parsed":"","local_part":"\\"test .s set .set\\"","local_part_parsed":"test .s set .set","domain_part":"asdf.ghjkl.com","domain":"asdf.ghjkl.com","ip":"","invalid":false,"invalid_reason":null}]}', '{"success":true,"reason":null,"email_addresses":[{"address":"*****@*****.**","simple_address":"*****@*****.**","original_address":"<*****@*****.**>","name":"","name_parsed":"","local_part":"t.name","local_part_parsed":"t.name","domain_part":"asdf.ghjkl.com","domain":"asdf.ghjkl.com","ip":"","invalid":false,"invalid_reason":null}]}', '{"success":true,"reason":null,"email_addresses":[{"address":"*****@*****.**","simple_address":"*****@*****.**","original_address":"<*****@*****.**>","name":"","name_parsed":"","local_part":"t.name.","local_part_parsed":"t.name.","domain_part":"asdf.ghjkl.com","domain":"asdf.ghjkl.com","ip":"","invalid":false,"invalid_reason":null}]}', '{"success":true,"reason":null,"email_addresses":[{"address":"*****@*****.**","simple_address":"*****@*****.**","original_address":"*****@*****.**","name":"","name_parsed":"","local_part":"tname","local_part_parsed":"tname","domain_part":"asdf.ghjkl.com","domain":"asdf.ghjkl.com","ip":"","invalid":false,"invalid_reason":null},{"address":"*****@*****.**","simple_address":"*****@*****.**","original_address":"*****@*****.**","name":"","name_parsed":"","local_part":"tname","local_part_parsed":"tname","domain_part":"asdf.ghjkl.com","domain":"asdf.ghjkl.com","ip":"","invalid":false,"invalid_reason":null},{"address":"*****@*****.**","simple_address":"*****@*****.**","original_address":"*****@*****.**","name":"","name_parsed":"","local_part":"tname-test1","local_part_parsed":"tname-test1","domain_part":"asdf.ghjkl.com","domain":"asdf.ghjkl.com","ip":"","invalid":false,"invalid_reason":null}]}', '{"success":false,"reason":"Invalid email address","email_addresses":[{"address":"tnam <e@asdf.g>","simple_address":"e@asdf.g","original_address":"tnam e@asdf.g","name":"tnam","name_parsed":"tnam","local_part":"e","local_part_parsed":"e","domain_part":"asdf.g","domain":"asdf.g","ip":"","invalid":false,"invalid_reason":null},{"address":"","simple_address":"","original_address":"asdfa hjkl.com","name":"asdfa","name_parsed":"asdfa","local_part":"","local_part_parsed":"","domain_part":"","domain":"","ip":"","invalid":true,"invalid_reason":"Misplaced Comma or missing \\"@\\" symbol"},{"address":"tn\'\'\'*****@*****.**","simple_address":"tn\'\'\'*****@*****.**","original_address":"tn\'\'\'*****@*****.**","name":"","name_parsed":"","local_part":"tn\'\'\'ame","local_part_parsed":"tn\'\'\'ame","domain_part":"asdf.ghjkl.com","domain":"asdf.ghjkl.com","ip":"","invalid":false,"invalid_reason":null},{"address":"*****@*****.**","simple_address":"*****@*****.**","original_address":"*****@*****.**","name":"","name_parsed":"","local_part":"tname-test1","local_part_parsed":"tname-test1","domain_part":"asdf.ghjkl.com","domain":"asdf.ghjkl.com","ip":"","invalid":false,"invalid_reason":null}]}', '{"success":true,"reason":null,"email_addresses":[{"address":"Testing D Name <*****@*****.**>","simple_address":"*****@*****.**","original_address":"Testing D Name <*****@*****.**>","name":"Testing D Name","name_parsed":"Testing D Name","local_part":"tname","local_part_parsed":"tname","domain_part":"asdf.ghjkl.com","domain":"asdf.ghjkl.com","ip":"","invalid":false,"invalid_reason":null},{"address":"*****@*****.**","simple_address":"*****@*****.**","original_address":"*****@*****.**","name":"","name_parsed":"","local_part":"tname","local_part_parsed":"tname","domain_part":"asdf.ghjkl.com","domain":"asdf.ghjkl.com","ip":"","invalid":false,"invalid_reason":null},{"address":"*****@*****.**","simple_address":"*****@*****.**","original_address":"*****@*****.**","name":"","name_parsed":"","local_part":"tname-test1","local_part_parsed":"tname-test1","domain_part":"asdf.ghjkl.com","domain":"asdf.ghjkl.com","ip":"","invalid":false,"invalid_reason":null}]}', '{"success":true,"reason":null,"email_addresses":[{"address":"Testing D Name <*****@*****.**>","simple_address":"*****@*****.**","original_address":"Testing D Name <*****@*****.**> (comment)","name":"Testing D Name","name_parsed":"Testing D Name","local_part":"tname","local_part_parsed":"tname","domain_part":"asdf.ghjkl.com","domain":"asdf.ghjkl.com","ip":"","invalid":false,"invalid_reason":null},{"address":"*****@*****.**","simple_address":"*****@*****.**","original_address":"tn(comment1)ame@asdf.gh(comment2)jkl.com","name":"","name_parsed":"","local_part":"tname","local_part_parsed":"tname","domain_part":"asdf.ghjkl.com","domain":"asdf.ghjkl.com","ip":"","invalid":false,"invalid_reason":null},{"address":"*****@*****.**","simple_address":"*****@*****.**","original_address":"tname-test1(comment3)@asdf.ghjkl.com","name":"","name_parsed":"","local_part":"tname-test1","local_part_parsed":"tname-test1","domain_part":"asdf.ghjkl.com","domain":"asdf.ghjkl.com","ip":"","invalid":false,"invalid_reason":null}]}', '{"success":false,"reason":"Invalid email address","email_addresses":[{"address":"","simple_address":"","original_address":"Tes!@#$@$&*&%(*ti)ng","name":"","name_parsed":"","local_part":"","local_part_parsed":"","domain_part":"","domain":"","ip":"","invalid":true,"invalid_reason":"This character is not allowed in email addresses submitted (please put in quotes if needed): \'!\'"},{"address":"D Name <*****@*****.**>","simple_address":"*****@*****.**","original_address":"D Name <*****@*****.**> (comment)","name":"D Name","name_parsed":"D Name","local_part":"tname","local_part_parsed":"tname","domain_part":"asdf.ghjkl.com","domain":"asdf.ghjkl.com","ip":"","invalid":false,"invalid_reason":null},{"address":"*****@*****.**","simple_address":"*****@*****.**","original_address":"tna(m!@#($(!(^)$)#)!^%#&*%^#)mment1e@asdf.gh(comment2)jkl.com","name":"","name_parsed":"","local_part":"tnamment1e","local_part_parsed":"tnamment1e","domain_part":"asdf.ghjkl.com","domain":"asdf.ghjkl.com","ip":"","invalid":false,"invalid_reason":null},{"address":"*****@*****.**","simple_address":"*****@*****.**","original_address":"tname-test1(comment3)@asdf.ghjkl.com","name":"","name_parsed":"","local_part":"tname-test1","local_part_parsed":"tname-test1","domain_part":"asdf.ghjkl.com","domain":"asdf.ghjkl.com","ip":"","invalid":false,"invalid_reason":null}]}', '{"success":false,"reason":"Invalid email address","email_addresses":[{"address":"","simple_address":"","original_address":"tname@[10.0.10.45]","name":"","name_parsed":"","local_part":"tname","local_part_parsed":"tname","domain_part":"[10.0.10.45]","domain":"","ip":"10.0.10.45","invalid":true,"invalid_reason":"IP address invalid (private): 10.0.10.45"},{"address":"*****@*****.**","simple_address":"*****@*****.**","original_address":"*****@*****.**","name":"","name_parsed":"","local_part":"tname","local_part_parsed":"tname","domain_part":"asdf.ghjkl.com","domain":"asdf.ghjkl.com","ip":"","invalid":false,"invalid_reason":null},{"address":"*****@*****.**","simple_address":"*****@*****.**","original_address":"*****@*****.**","name":"","name_parsed":"","local_part":"tname-test2","local_part_parsed":"tname-test2","domain_part":"asdf.ghjkl.com","domain":"asdf.ghjkl.com","ip":"","invalid":false,"invalid_reason":null}]}', '{"success":false,"reason":"Invalid email address","email_addresses":[{"address":"","simple_address":"","original_address":"t\\"na\\"me@[10.0.10.45]","name":"","name_parsed":"","local_part":"\\"tname\\"","local_part_parsed":"tname","domain_part":"[10.0.10.45]","domain":"","ip":"10.0.10.45","invalid":true,"invalid_reason":"IP address invalid (private): 10.0.10.45"},{"address":"*****@*****.**","simple_address":"*****@*****.**","original_address":"*****@*****.**","name":"","name_parsed":"","local_part":"tname","local_part_parsed":"tname","domain_part":"asdf.ghjkl.com","domain":"asdf.ghjkl.com","ip":"","invalid":false,"invalid_reason":null},{"address":"*****@*****.**","simple_address":"*****@*****.**","original_address":"*****@*****.**","name":"","name_parsed":"","local_part":"tname-test2","local_part_parsed":"tname-test2","domain_part":"asdf.ghjkl.com","domain":"asdf.ghjkl.com","ip":"","invalid":false,"invalid_reason":null}]}', '{"success":false,"reason":"Invalid email address","email_addresses":[{"address":"","simple_address":"","original_address":"t(comment with spaces !!!)name@[10.0.10.45]","name":"","name_parsed":"","local_part":"tname","local_part_parsed":"tname","domain_part":"[10.0.10.45]","domain":"","ip":"10.0.10.45","invalid":true,"invalid_reason":"IP address invalid (private): 10.0.10.45"},{"address":"*****@*****.**","simple_address":"*****@*****.**","original_address":"*****@*****.**","name":"","name_parsed":"","local_part":"tname","local_part_parsed":"tname","domain_part":"asdf.ghjkl.com","domain":"asdf.ghjkl.com","ip":"","invalid":false,"invalid_reason":null},{"address":"*****@*****.**","simple_address":"*****@*****.**","original_address":"*****@*****.**","name":"","name_parsed":"","local_part":"tname-test2","local_part_parsed":"tname-test2","domain_part":"asdf.ghjkl.com","domain":"asdf.ghjkl.com","ip":"","invalid":false,"invalid_reason":null}]}', '{"success":true,"reason":null,"email_addresses":[{"address":"*****@*****.**","simple_address":"*****@*****.**","original_address":"testing@t\\u016bdali\\u0146.lv","name":"","name_parsed":"","local_part":"testing","local_part_parsed":"testing","domain_part":"xn--tdali-d8a8w.lv","domain":"xn--tdali-d8a8w.lv","ip":"","invalid":false,"invalid_reason":null}]}', '{"success":true,"reason":null,"email_addresses":[{"address":"*****@*****.**","simple_address":"*****@*****.**","original_address":"*****@*****.**","name":"","name_parsed":"","local_part":"testing","local_part_parsed":"testing","domain_part":"xn--tdali-d8a8w.lv","domain":"xn--tdali-d8a8w.lv","ip":"","invalid":false,"invalid_reason":null}]}', '{"success":false,"reason":"Invalid email address","email_addresses":[{"address":"","simple_address":"","original_address":"*****@*****.**","name":"","name_parsed":"","local_part":"testing","local_part_parsed":"testing","domain_part":"-bad-domain.com","domain":"-bad-domain.com","ip":"","invalid":true,"invalid_reason":"Domain invalid: Parts of the domain name \'-bad-domain.com\' can not start or end with \'-\'.  This part does: -bad-domain"}]}', '{"success":false,"reason":"Invalid email address","email_addresses":[{"address":"","simple_address":"","original_address":"testing@192.168.0.1","name":"","name_parsed":"","local_part":"testing","local_part_parsed":"testing","domain_part":"[192.168.0.1]","domain":null,"ip":"192.168.0.1","invalid":true,"invalid_reason":"IP address invalid (private): 192.168.0.1"}]}', '{"success":false,"reason":"Invalid email address","email_addresses":[{"address":"","simple_address":"","original_address":"testing@256.26.52.5","name":"","name_parsed":"","local_part":"testing","local_part_parsed":"testing","domain_part":"[256.26.52.5]","domain":null,"ip":"256.26.52.5","invalid":true,"invalid_reason":"IP address invalid: \'256.26.52.5\' does not appear to be a valid IP address"}]}', '{"success":false,"reason":"Invalid email address","email_addresses":[{"address":"","simple_address":"","original_address":"testing@[256.26.52.5]","name":"","name_parsed":"","local_part":"testing","local_part_parsed":"testing","domain_part":"[256.26.52.5]","domain":"","ip":"256.26.52.5","invalid":true,"invalid_reason":"IP address invalid: \'256.26.52.5\' does not appear to be a valid IP address"}]}', '{"success":false,"reason":"Invalid email address","email_addresses":[{"address":"","simple_address":"","original_address":"testing@[299.236.532.265]","name":"","name_parsed":"","local_part":"testing","local_part_parsed":"testing","domain_part":"[299.236.532.265]","domain":"","ip":"299.236.532.265","invalid":true,"invalid_reason":"IP address invalid: \'299.236.532.265\' does not appear to be a valid IP address"}]}', '{"success":true,"reason":null,"email_addresses":[{"address":"testing@[80.67.66.65]","simple_address":"testing@[80.67.66.65]","original_address":"testing@[80.67.66.65]","name":"","name_parsed":"","local_part":"testing","local_part_parsed":"testing","domain_part":"[80.67.66.65]","domain":"","ip":"80.67.66.65","invalid":false,"invalid_reason":null}]}', '{"success":true,"reason":null,"email_addresses":[{"address":"testing@[80.67.66.65]","simple_address":"testing@[80.67.66.65]","original_address":"testing@80.67.66.65","name":"","name_parsed":"","local_part":"testing","local_part_parsed":"testing","domain_part":"[80.67.66.65]","domain":null,"ip":"80.67.66.65","invalid":false,"invalid_reason":null}]}');
     $results2 = array('{"address":"\\"Testing D. Name\\" <*****@*****.**>","simple_address":"*****@*****.**","original_address":"\\"Testing D. Name\\" <*****@*****.**>","name":"\\"Testing D. Name\\"","name_parsed":"Testing D. Name","local_part":"tname","local_part_parsed":"tname","domain_part":"asdf.ghjkl.com","domain":"asdf.ghjkl.com","ip":"","invalid":false,"invalid_reason":null}', '{"address":"*****@*****.**","simple_address":"*****@*****.**","original_address":"<*****@*****.**>","name":"","name_parsed":"","local_part":"tname","local_part_parsed":"tname","domain_part":"asdf.ghjkl.com","domain":"asdf.ghjkl.com","ip":"","invalid":false,"invalid_reason":null}', '{"address":"","simple_address":"","original_address":"<*****@*****.**>","name":"","name_parsed":"","local_part":"","local_part_parsed":"","domain_part":"","domain":"","ip":"","invalid":true,"invalid_reason":"Email address can not start with \'.\'"}', '{"address":"\\"test .s set .set\\"@asdf.ghjkl.com","simple_address":"\\"test .s set .set\\"@asdf.ghjkl.com","original_address":"\\"test .s set .set\\"@asdf.ghjkl.com","name":"","name_parsed":"","local_part":"\\"test .s set .set\\"","local_part_parsed":"test .s set .set","domain_part":"asdf.ghjkl.com","domain":"asdf.ghjkl.com","ip":"","invalid":false,"invalid_reason":null}', '{"address":"*****@*****.**","simple_address":"*****@*****.**","original_address":"<*****@*****.**>","name":"","name_parsed":"","local_part":"t.name","local_part_parsed":"t.name","domain_part":"asdf.ghjkl.com","domain":"asdf.ghjkl.com","ip":"","invalid":false,"invalid_reason":null}', '{"address":"*****@*****.**","simple_address":"*****@*****.**","original_address":"<*****@*****.**>","name":"","name_parsed":"","local_part":"t.name.","local_part_parsed":"t.name.","domain_part":"asdf.ghjkl.com","domain":"asdf.ghjkl.com","ip":"","invalid":false,"invalid_reason":null}', '{"address":"","simple_address":"","original_address":"tname@asdf.ghjkl.com, tname@asdf.ghjkl.com, tname-test1@asdf.ghjkl.com","name":"","name_parsed":"","local_part":"tname","local_part_parsed":"tname","domain_part":"asdf.ghjkl.com","domain":"asdf.ghjkl.com","ip":"","invalid":true,"invalid_reason":"Comma not permitted - only one email address allowed"}', '{"address":"tnam <e@asdf.g>","simple_address":"e@asdf.g","original_address":"tnam e@asdf.g","name":"tnam","name_parsed":"tnam","local_part":"e","local_part_parsed":"e","domain_part":"asdf.g","domain":"asdf.g","ip":"","invalid":false,"invalid_reason":null}', '{"address":"Testing D Name <*****@*****.**>","simple_address":"*****@*****.**","original_address":"Testing D Name <*****@*****.**>","name":"Testing D Name","name_parsed":"Testing D Name","local_part":"tname","local_part_parsed":"tname","domain_part":"asdf.ghjkl.com","domain":"asdf.ghjkl.com","ip":"","invalid":false,"invalid_reason":null}', '{"address":"Testing D Name <*****@*****.**>","simple_address":"*****@*****.**","original_address":"Testing D Name <*****@*****.**> (comment)","name":"Testing D Name","name_parsed":"Testing D Name","local_part":"tname","local_part_parsed":"tname","domain_part":"asdf.ghjkl.com","domain":"asdf.ghjkl.com","ip":"","invalid":false,"invalid_reason":null}', '{"address":"","simple_address":"","original_address":"Tes!@#$@$&*&%(*ti)ng D Name <*****@*****.**> (comment) tna(m!@#($(!(^)$)#)!^%#&*%^#)mment1e@asdf.gh(comment2)jkl.com tname-test1(comment3)@asdf.ghjkl.com","name":"","name_parsed":"","local_part":"","local_part_parsed":"","domain_part":"","domain":"","ip":"","invalid":true,"invalid_reason":"This character is not allowed in email addresses submitted (please put in quotes if needed): \'!\'"}', '{"address":"","simple_address":"","original_address":"tname@[10.0.10.45]","name":"","name_parsed":"","local_part":"tname","local_part_parsed":"tname","domain_part":"[10.0.10.45]","domain":"","ip":"10.0.10.45","invalid":true,"invalid_reason":"IP address invalid (private): 10.0.10.45"}', '{"address":"","simple_address":"","original_address":"t\\"na\\"me@[10.0.10.45]","name":"","name_parsed":"","local_part":"\\"tname\\"","local_part_parsed":"tname","domain_part":"[10.0.10.45]","domain":"","ip":"10.0.10.45","invalid":true,"invalid_reason":"IP address invalid (private): 10.0.10.45"}', '{"address":"","simple_address":"","original_address":"t(comment with spaces !!!)name@[10.0.10.45]","name":"","name_parsed":"","local_part":"tname","local_part_parsed":"tname","domain_part":"[10.0.10.45]","domain":"","ip":"10.0.10.45","invalid":true,"invalid_reason":"IP address invalid (private): 10.0.10.45"}', '{"address":"*****@*****.**","simple_address":"*****@*****.**","original_address":"testing@t\\u016bdali\\u0146.lv","name":"","name_parsed":"","local_part":"testing","local_part_parsed":"testing","domain_part":"xn--tdali-d8a8w.lv","domain":"xn--tdali-d8a8w.lv","ip":"","invalid":false,"invalid_reason":null}', '{"address":"*****@*****.**","simple_address":"*****@*****.**","original_address":"*****@*****.**","name":"","name_parsed":"","local_part":"testing","local_part_parsed":"testing","domain_part":"xn--tdali-d8a8w.lv","domain":"xn--tdali-d8a8w.lv","ip":"","invalid":false,"invalid_reason":null}', '{"address":"","simple_address":"","original_address":"*****@*****.**","name":"","name_parsed":"","local_part":"testing","local_part_parsed":"testing","domain_part":"-bad-domain.com","domain":"-bad-domain.com","ip":"","invalid":true,"invalid_reason":"Domain invalid: Parts of the domain name \'-bad-domain.com\' can not start or end with \'-\'.  This part does: -bad-domain"}', '{"address":"","simple_address":"","original_address":"testing@192.168.0.1","name":"","name_parsed":"","local_part":"testing","local_part_parsed":"testing","domain_part":"[192.168.0.1]","domain":null,"ip":"192.168.0.1","invalid":true,"invalid_reason":"IP address invalid (private): 192.168.0.1"}', '{"address":"","simple_address":"","original_address":"testing@256.26.52.5","name":"","name_parsed":"","local_part":"testing","local_part_parsed":"testing","domain_part":"[256.26.52.5]","domain":null,"ip":"256.26.52.5","invalid":true,"invalid_reason":"IP address invalid: \'256.26.52.5\' does not appear to be a valid IP address"}', '{"address":"","simple_address":"","original_address":"testing@[256.26.52.5]","name":"","name_parsed":"","local_part":"testing","local_part_parsed":"testing","domain_part":"[256.26.52.5]","domain":"","ip":"256.26.52.5","invalid":true,"invalid_reason":"IP address invalid: \'256.26.52.5\' does not appear to be a valid IP address"}', '{"address":"","simple_address":"","original_address":"testing@[299.236.532.265]","name":"","name_parsed":"","local_part":"testing","local_part_parsed":"testing","domain_part":"[299.236.532.265]","domain":"","ip":"299.236.532.265","invalid":true,"invalid_reason":"IP address invalid: \'299.236.532.265\' does not appear to be a valid IP address"}', '{"address":"testing@[80.67.66.65]","simple_address":"testing@[80.67.66.65]","original_address":"testing@[80.67.66.65]","name":"","name_parsed":"","local_part":"testing","local_part_parsed":"testing","domain_part":"[80.67.66.65]","domain":"","ip":"80.67.66.65","invalid":false,"invalid_reason":null}', '{"address":"testing@[80.67.66.65]","simple_address":"testing@[80.67.66.65]","original_address":"testing@80.67.66.65","name":"","name_parsed":"","local_part":"testing","local_part_parsed":"testing","domain_part":"[80.67.66.65]","domain":null,"ip":"80.67.66.65","invalid":false,"invalid_reason":null}');
     for ($i = 0; $i < count($emails); $i++) {
         $a = Parse::getInstance()->parse($emails[$i]);
         $b = Parse::getInstance()->parse($emails[$i], false);
         $this->assertEquals($results1[$i], json_encode($a));
         $this->assertEquals($results2[$i], json_encode($b));
     }
 }