PHP Classes

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

Recommend this page to a friend!
  Packages of Marcelo Santos   Melody Validation   tests/src/Melody/Validation/Constraints/StringTest.php   Download  
File: tests/src/Melody/Validation/Constraints/StringTest.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: 13 years ago
Size: 828 bytes
 

 

Contents

Class file image Download
<?php

namespace Melody\Validation\Constraints;

use Melody\Validation\Validator as v;

class StringTest extends \PHPUnit_Framework_TestCase
{

    /**
     * @dataProvider validStringProvider
     */
    public function test_valid_string_should_work($input)
    {
        $this->assertTrue(v::string()->validate($input));
    }

    /**
     * @dataProvider invalidStringProvider
     */
    public function test_invalid_string_should_not_work($input)
    {
        $this->assertFalse(v::string()->validate($input));
    }

    public function validStringProvider()
    {
        return array(
            array('12.87'),
            array(''),
        );
    }

    public function invalidStringProvider()
    {
        return array(
            array(null),
            array(13.4),
            array(255)
        );
    }
}