PHP Classes
elePHPant
Icontem

File: unit-test/required.test.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Can Gelis  >  Simple PHP Validation class  >  unit-test/required.test.php  >  Download  
File: unit-test/required.test.php
Role: Unit test script
Content type: text/plain
Description: Unit test script
Class: Simple PHP Validation class
Validate string value according to different rules
Author: By
Last change: fixed #1
Date: 2 years ago
Size: 1,956 bytes
 

Contents

Class file image Download
<?php

class RequiredTest extends PHPUnit_Framework_TestCase {

    public
$rules;

    public function
setUp() {
       
$this->rules = array(
           
'test' => array('required')
        );
    }

    public function
tearDown() {
       
    }

    public function
testEmptyInput() {
       
$inputs = array(
           
'test' => ''
       
);
       
$validator = SimpleValidator\Validator::validate($inputs, $this->rules);
       
$this->assertEquals($validator->isSuccess(), false);
    }

    public function
testNullInput() {
       
$inputs = array(
           
'test' => null
       
);
       
$validator = SimpleValidator\Validator::validate($inputs, $this->rules);
       
$this->assertEquals($validator->isSuccess(), false);
    }

    public function
testOnlyWhiteSpaceInput() {
       
$inputs = array(
           
'test' => ' '
       
);
       
$validator = SimpleValidator\Validator::validate($inputs, $this->rules);
       
$this->assertEquals($validator->isSuccess(), false);
    }

    public function
testUnassignedInput() {
       
$inputs = array();
       
$validator = SimpleValidator\Validator::validate($inputs, $this->rules);
       
$this->assertEquals($validator->isSuccess(), false);
    }

    public function
testNullInputArray() {
       
$inputs = null;
       
$validator = SimpleValidator\Validator::validate($inputs, $this->rules);
       
$this->assertEquals($validator->isSuccess(), false);
    }

    public function
testZeroInput() {
       
$inputs = array(
           
'test' => '0'
       
);
       
$validator = SimpleValidator\Validator::validate($inputs, $this->rules);
       
$this->assertEquals($validator->isSuccess(), true);
    }

    public function
testZeroPointZeroInput() {
       
$inputs = array(
           
'test' => 0.0
       
);
       
$validator = SimpleValidator\Validator::validate($inputs, $this->rules);
       
$this->assertEquals($validator->isSuccess(), true);
    }

}

?>