Create integration tests for "AllOf" rule

This commit is contained in:
Edson Lima 2015-10-21 02:03:02 -02:00 committed by Henrique Moody
parent 03c0bd03de
commit fd6fcd151e
5 changed files with 74 additions and 0 deletions

View file

@ -0,0 +1,12 @@
--FILE--
<?php
require 'vendor/autoload.php';
use Respect\Validation\Validator as v;
v::allOf(v::intVal(), v::positive())->assert(42);
v::allOf(v::intVal(), v::negative())->check(-42);
v::not(v::allOf(v::date(), v::between('2014-12-01', '2014-12-12')))->assert('2012-01-01');
v::not(v::allOf(v::stringType(), v::consonant()))->check('I am Jack\'s smirking revenge');
?>
--EXPECTF--

View file

@ -0,0 +1,15 @@
--FILE--
<?php
require 'vendor/autoload.php';
use Respect\Validation\Validator as v;
use Respect\Validation\Exceptions\ConsonantException;
try {
v::allOf(v::stringType(), v::consonant())->check('Luke i\'m your father');
} catch (ConsonantException $e) {
echo $e->getMainMessage();
}
?>
--EXPECTF--
"Luke i'm your father" must contain only consonants

View file

@ -0,0 +1,17 @@
--FILE--
<?php
require 'vendor/autoload.php';
use Respect\Validation\Validator as v;
use Respect\Validation\Exceptions\AllOfException;
try {
v::allOf(v::stringType(), v::consonant())->assert(42);
} catch (AllOfException $e) {
echo $e->getFullMessage();
}
?>
--EXPECTF--
\-All of the required rules must pass for 42
|-42 must be a string
\-42 must contain only consonants

View file

@ -0,0 +1,15 @@
--FILE--
<?php
require 'vendor/autoload.php';
use Respect\Validation\Validator as v;
use Respect\Validation\Exceptions\IntTypeException;
try {
v::not(v::allOf(v::intType(), v::positive()))->check(42);
} catch (IntTypeException $e) {
echo $e->getMainMessage();
}
?>
--EXPECTF--
42 must not be of the type integer

View file

@ -0,0 +1,15 @@
--FILE--
<?php
require 'vendor/autoload.php';
use Respect\Validation\Validator as v;
use Respect\Validation\Exceptions\AllOfException;
try {
v::not(v::allOf(v::stringType(), v::length(10)))->assert('Frank Zappa is fantastic');
} catch (AllOfException $e) {
echo $e->getFullMessage();
}
?>
--EXPECTF--
\-"Frank Zappa is fantastic" must not be string