mirror of
https://github.com/Respect/Validation.git
synced 2024-06-28 02:00:06 +02:00
Create integration tests for "AllOf" rule
This commit is contained in:
parent
03c0bd03de
commit
fd6fcd151e
12
tests/integration/allOf_1.phpt
Normal file
12
tests/integration/allOf_1.phpt
Normal 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--
|
15
tests/integration/allOf_2.phpt
Normal file
15
tests/integration/allOf_2.phpt
Normal 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
|
17
tests/integration/allOf_3.phpt
Normal file
17
tests/integration/allOf_3.phpt
Normal 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
|
15
tests/integration/allOf_4.phpt
Normal file
15
tests/integration/allOf_4.phpt
Normal 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
|
15
tests/integration/allOf_5.phpt
Normal file
15
tests/integration/allOf_5.phpt
Normal 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
|
Loading…
Reference in a new issue