PHP Classes

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

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

Contents

Class file image Download
<?php

namespace Melody\Validation\Constraints;

use
Melody\Validation\Validator as v;

class
ContainsLetterTest extends \PHPUnit_Framework_TestCase
{

    public function
test_valid_string_should_pass()
    {
       
$this->assertTrue(v::containsSpecial(1)->validate('abcdef@0123'));
    }

    public function
test_invalid_string_should_fail_validation()
    {
       
$this->assertFalse(v::containsSpecial(1)->validate('abcdef0123'));
    }

    public function
test_invalid_argument_exception()
    {
       
$this->setExpectedException('InvalidArgumentException');
       
$this->assertInstanceOf('InvalidArgumentException', v::containsSpecial("invalid argument"));
    }

    public function
test_not_string_argument_exception()
    {
       
$this->setExpectedException('InvalidArgumentException');
       
$this->assertInstanceOf('InvalidArgumentException', v::containsSpecial(5)->validate(null));
    }

}