Login   Register  
PHP Classes
elePHPant
Icontem

File: unit-test/ip.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/ip.test.php  >  Download  
File: unit-test/ip.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: Merge branch 'master' of github.com:cangelis/simple-validator.git
Date: 2013-05-06 07:01
Size: 1,323 bytes
 

Contents

Class file image Download
<?php

class IPTest extends PHPUnit_Framework_TestCase {

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

    public function 
tearDown() {
        
    }

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

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

    public function 
testValidIPv6Input() {
        
$inputs = array(
            
'test' => "2a03:2880:10:1f02:face:b00c::25"
        
);
        
$validator SimpleValidator\Validator::validate($inputs$this->rules);
        
$this->assertEquals($validator->isSuccess(), true);
    }

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

}

?>