<?php
 
require_once 'validator.class.php';
 
require_once 'gunit.class.php';
 
 
 
class ValidatorTest extends GUnit {
 
    function testEmail(){
 
        $o = new Validator;
 
        $o->setEmail( 'gmomchilov@gmail.com' );
 
        return ( $o->ValidateEmail() === true ) ? true : false;
 
    }
 
    
 
    function testFalseEmail(){
 
        $o = new Validator;
 
        $o->setEmail( 'gmomchilov@.gmail.comchi' );
 
        return ( $o->ValidateEmail() === false ) ? true : false;
 
    }
 
    
 
    function testUsername(){
 
        $o = new Validator;
 
        $o->setUsername( 'gmomchilov' );
 
        return ( $o->ValidateUsername() === true ) ? true : false;
 
    }  
 
    
 
    function testFalseUsername(){
 
        $o = new Validator;
 
        $o->setUsername( '^%$DSA@' );
 
        return ( $o->ValidateUsername() === false ) ? true : false;
 
    }  
 
    
 
    function testPasswords(){
 
        $o = new Validator;
 
        $o->setPasswords( 'gmmml', 'gmmml' );
 
        return ( $o->ValidatePasswords() === true ) ? true : false;
 
    }  
 
    
 
    function testFalsePasswords(){
 
        $o = new Validator;
 
        $o->setPasswords( 'gmmml@', '#gmmml' );
 
        return ( $o->ValidatePasswords() === false ) ? true : false;
 
    }
 
    
 
    function testValidate(){
 
    $o = new Validator;
 
        $o->setPasswords( 'gmmmla', 'gmmmla' );
 
    $o->setUsername( 'gmomchilov' );
 
    $o->setEmail( 'gmomchilov@gmail.com' );
 
    return ( $o->Validate() === true ) ? true : false;
 
    }  
 
    
 
    function testFalseValidate(){
 
    $o = new Validator;
 
        $o->setPasswords( 'mmmla', 'gmmmla' );
 
    $o->setUsername( 'gmomchilo#v' );
 
    $o->setEmail( '@gmail.com' );
 
    return ( $o->Validate() === false ) ? true : false;
 
   }
 
}
 
$o = new ValidatorTest;
 
$o->run();
 
?>
 
 |