File: email_domaincheck.phpt

package info (click to toggle)
php-validate 0.8.5-4.2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 244 kB
  • sloc: php: 758; xml: 492; makefile: 2
file content (49 lines) | stat: -rw-r--r-- 1,363 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
--TEST--
domaincheck.phpt: Unit tests for email validation with dns checks
--SKIPIF--
<?php
if (!function_exists('checkdnsrr') || !checkdnsrr('php.net', 'A')) {
    echo 'skip Missing checkdnsrr()';
}
?>
--FILE--
<?php
// $Id: email.phpt 276490 2009-02-26 09:32:16Z amir $
// Validate test script
$noYes = array('NO', 'YES');
require 'Validate.php';

echo "Test Validate_Email\n";

$emails = array(
        // Try dns lookup
        array('pear-general@lists.php.net', true), // OK
        array('example@fluffffffrefrffrfrfrfrfrfr.is', true) // OK
    );

list($version) = explode(".", phpversion(), 2);
foreach ($emails as $email) {
    if (is_array($email)) {
        echo "{$email[0]}:";
        if (!is_array($email[1])) {
            echo " with". ($email[1] ? '' : 'out') . ' domain check :';
        }
        echo ' ' . $noYes[Validate::email($email[0], $email[1])]."\n";
    } else {
        echo "{$email}: ";
        if ((int)$version > 4) {
            try {
                echo $noYes[Validate::email($email)]."\n";
            } catch (Exception $e) {
                echo $e->getMessage()."\n";
            }
        } else {
            echo $noYes[Validate::email($email)]."\n";
        }
    }
}
?>
--EXPECT--
Test Validate_Email
pear-general@lists.php.net: with domain check : YES
example@fluffffffrefrffrfrfrfrfrfr.is: with domain check : NO