Login   Register  
PHP Classes
elePHPant
Icontem

File: tests/src/Melody/Validation/Constraints/RangeTest.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Marcelo Santos  >  Melody Validation  >  tests/src/Melody/Validation/Constraints/RangeTest.php  >  Download  
File: tests/src/Melody/Validation/Constraints/RangeTest.php
Role: Unit test script
Content type: text/plain
Description: Unit test script
Class: Melody Validation
Validate values according to many types of rules
Author: By
Last change:
Date: 2013-10-17 20:23
Size: 1,614 bytes
 

Contents

Class file image Download
<?php

namespace Melody\Validation\Constraints;

use 
Melody\Validation\Validator as v;

class 
RangeTest extends \PHPUnit_Framework_TestCase
{

    public function 
test_valid_number_should_pass()
    {
        
$this->assertTrue(v::range(510)->validate(5));
        
$this->assertTrue(v::range(510)->validate(6));
        
$this->assertTrue(v::range(510)->validate(7));
        
$this->assertTrue(v::range(510)->validate(8));
        
$this->assertTrue(v::range(510)->validate(9));
        
$this->assertTrue(v::range(510)->validate(10));
    }

    public function 
test_invalid_number_should_fail_validation()
    {
        
$this->assertFalse(v::range(510)->validate(3));
        
$this->assertFalse(v::range(510)->validate(4));
        
$this->assertFalse(v::range(510)->validate(11));
        
$this->assertFalse(v::range(510)->validate(12));
    }

    public function 
test_invalid_argument_exception_min()
    {
        
$this->setExpectedException('InvalidArgumentException');
        
$this->assertInstanceOf('InvalidArgumentException'v::range("invalid argument"10)->validate(3));
    }

    public function 
test_invalid_argument_exception_max()
    {
        
$this->setExpectedException('InvalidArgumentException');
        
$this->assertInstanceOf('InvalidArgumentException'v::range(5"invalid argument")->validate(3));
    }

    public function 
test_invalid_argument_exception_not_int()
    {
        
$this->setExpectedException('InvalidArgumentException');
        
$this->assertInstanceOf('InvalidArgumentException'v::range(510)->validate("invalid argument"));
    }

}