Login   Register  
PHP Classes
elePHPant
Icontem

File: tests/src/Melody/Validation/Constraints/NotEmptyTest.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/NotEmptyTest.php  >  Download  
File: tests/src/Melody/Validation/Constraints/NotEmptyTest.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 months ago
Size: 975 bytes
 

Contents

Class file image Download
<?php

namespace Melody\Validation\Constraints;

use 
Melody\Validation\Validator as v;

class 
NotEmptyTest extends \PHPUnit_Framework_TestCase
{

    
/**
     * @dataProvider providerForNotEmpty
     */
    
public function test_valid_string_should_pass($input)
    {
        
$this->assertTrue(v::notEmpty()->validate($input));
    }

    
/**
     * @dataProvider providerForEmpty
     */
    
public function test_invalid_string_should_fail_validation($input)
    {
        
$this->assertFalse(v::notEmpty()->validate($input));
    }

    public function 
providerForNotEmpty()
    {
        return array(
            array(new \
stdClass),
            array(array(
666)),
            array(array(
0)),
            array(
' name'),
            array(
1)
        );
    }

    public function 
providerForEmpty()
    {
        return array(
            array(
''),
            array(
'    '),
            array(
"\n"),
            array(
false),
            array(
null)
        );
    }
}