PHP Classes

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

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

Contents

Class file image Download
<?php

namespace Melody\Validation\Constraints;

use
Melody\Validation\Validator as v;

class
MinLengthTest extends \PHPUnit_Framework_TestCase
{

   
/**
     * @dataProvider providerForValidStrings
     */
   
public function test_valid_string_should_pass($validString)
    {
       
$this->assertTrue(v::minLength(3)->validate($validString));
    }

   
/**
     * @dataProvider providerForInvalidStrings
     */
   
public function test_invalid_string_should_fail_validation($invalidString)
    {
       
$this->assertFalse(v::minLength(10)->validate($invalidString));
    }

    public function
providerForValidStrings()
    {
        return array(
                array(
'abc'),
                array(
'abcdef'),
                array(
'abcdef1234')
        );
    }

    public function
providerForInvalidStrings()
    {
        return array(
                array(
'abcd'),
                array(
'abcdef'),
                array(
'abcdef123')
        );
    }

}