Create integration tests for "Age" role

This commit is contained in:
William Espindola 2015-10-17 15:44:54 -03:00 committed by Henrique Moody
parent f2083a58d7
commit ecbc5c0a94
4 changed files with 62 additions and 0 deletions

View file

@ -0,0 +1,11 @@
--FILE--
<?php
require 'vendor/autoload.php';
use Respect\Validation\Validator as v;
v::age(18)->assert('18 years ago');
v::age(18)->check('18 years ago');
?>
--EXPECTF--

View file

@ -0,0 +1,17 @@
--FILE--
<?php
require 'vendor/autoload.php';
use Respect\Validation\Validator as v;
use Respect\Validation\Exceptions\MaxException;
try {
v::age(18)->check('17 years ago');
} catch (MaxException $e) {
echo $e->getMainMessage();
}
?>
--EXPECTF--
"17 years ago" must be less than or equal to "1997-11-09 23:59:59"

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::age(18)->assert('17 years ago');
} catch (AllOfException $e) {
echo $e->getFullMessage();
}
?>
--EXPECTF--
- "17 years ago" must be less than or equal to "1997-11-09 23:59:59"

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::age(10, 50)->assert('9 years ago');
} catch (AllOfException $e) {
echo $e->getFullMessage();
}
?>
--EXPECTF--
- "9 years ago" must be less than or equal to "2005-11-09 23:59:59"