PHP Classes
elePHPant
Icontem

File: tests/src/Melody/Validation/Constraints/NumberTest.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/NumberTest.php  >  Download  
File: tests/src/Melody/Validation/Constraints/NumberTest.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: 1 year ago
Size: 888 bytes
 

Contents

Class file image Download
<?php

namespace Melody\Validation\Constraints;

use
Melody\Validation\Validator as v;

class
NumberTest extends \PHPUnit_Framework_TestCase
{

   
/**
     * @dataProvider validNumberProvider
     */
   
public function test_valid_number_should_work($input)
    {
       
$this->assertTrue(v::number()->validate($input));
    }

   
/**
     * @dataProvider invalidNumberProvider
     */
   
public function test_invalid_number_should_not_work($input)
    {
       
$this->assertFalse(v::number()->validate($input));
    }

    public function
validNumberProvider()
    {
        return array(
            array(
1),
            array(
"2"),
            array(
10 / 2),
            array(
10 % 2),
            array((int) (
10 / 3))
        );
    }

    public function
invalidNumberProvider()
    {
        return array(
            array(
null),
            array(
"@")
        );
    }
}