<?php
 
require 'config.php';
 
 
function testEmail($email)
 
{
 
  echo $email;
 
  $rule = new A_Rule_Email('email', 'error message');
 
  $pass = $rule->isValid(array('email'=>$email));
 
  if ($pass)
 
  {
 
    echo " is valid.\n";
 
  }
 
  else
 
  {
 
    echo " is not valid.\n";
 
  }
 
  return $pass;
 
}
 
 
$pass = true;
 
echo "All of these should succeed:\n";
 
$pass &= testEmail("[email protected]");
 
$pass &= testEmail("abc\\@[email protected]");
 
$pass &= testEmail("abc\\\\@example.com");
 
$pass &= testEmail("Fred\\ [email protected]");
 
$pass &= testEmail("Joe.\\\\[email protected]");
 
$pass &= testEmail("\"Abc@def\"@example.com");
 
$pass &= testEmail("\"Fred Bloggs\"@example.com");
 
$pass &= testEmail("customer/[email protected]");
 
$pass &= testEmail("\[email protected]");
 
$pass &= testEmail("!def!xyz%[email protected]");
 
$pass &= testEmail("[email protected]");
 
$pass &= testEmail("[email protected]");
 
$pass &= testEmail("[email protected]");
 
$pass &= testEmail("Doug\\ \\\"Ace\\\"\\ [email protected]");
 
$pass &= testEmail("\"Doug \\\"Ace\\\" L.\"@example.com");
 
echo "\nAll of these should fail:\n";
 
$pass &= !testEmail("abc@[email protected]");
 
$pass &= !testEmail("abc\\\\@[email protected]");
 
$pass &= !testEmail("abc\\@example.com");
 
$pass &= !testEmail("@example.com");
 
$pass &= !testEmail("doug@");
 
$pass &= !testEmail("\"[email protected]");
 
$pass &= !testEmail("ote\"@example.com");
 
$pass &= !testEmail("[email protected]");
 
$pass &= !testEmail("[email protected]");
 
$pass &= !testEmail("[email protected]");
 
$pass &= !testEmail("\"Doug \"Ace\" L.\"@example.com");
 
$pass &= !testEmail("Doug\\ \\\"Ace\\\"\\ L\\[email protected]");
 
$pass &= !testEmail("hello [email protected]");
 
$pass &= !testEmail("[email protected].");
 
echo "\nThe email validation ";
 
if ($pass)
 
{
 
   echo "passes all tests.\n";
 
}
 
else
 
{
 
   echo "is deficient.\n";
 
}
 
 
 |