Location: PHPKode > scripts > GUnit > gunit/example.php
<?php
require_once 'validator.class.php';
require_once 'gunit.class.php';
 
class ValidatorTest extends GUnit {
    function testEmail(){
        $o = new Validator;
        $o->setEmail( 'hide@address.com' );
        return ( $o->ValidateEmail() === true ) ? true : false;
    }
    
    function testFalseEmail(){
        $o = new Validator;
        $o->setEmail( 'hide@address.com' );
        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( 'hide@address.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();
?>
Return current item: GUnit