PHP Classes

File: examples/rule/test_email_rule.php

Recommend this page to a friend!
  Classes of Haseeb Ahmad Basil   PHP Skeleton Framework   ???   Download  
File: examples/rule/???
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Skeleton Framework
Extensive Web application development framework
Author: By
Last change:
Date: 9 years ago
Size: 1,926 bytes
 

Contents

Class file image Download
<?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";
}