Create integration tests for "ObjectType" rule

This commit is contained in:
Rafael-BP 2015-10-17 17:32:43 -03:00 committed by Henrique Moody
parent cbbf082c15
commit 6fb15a697c
4 changed files with 76 additions and 0 deletions

View file

@ -0,0 +1,10 @@
--FILE--
<?php
require 'vendor/autoload.php';
use Respect\Validation\Validator as v;
v::objectType()->assert(new stdClass);
v::objectType()->check(new stdClass);
?>
--EXPECTF--

View file

@ -0,0 +1,29 @@
--FILE--
<?php
require 'vendor/autoload.php';
use Respect\Validation\Validator as v;
use Respect\Validation\Exceptions\ObjectTypeException;
try {
v::objectType()->check('');
} catch (ObjectTypeException $exception) {
echo $exception->getMainMessage().PHP_EOL;
}
try {
v::objectType()->check(true);
} catch (ObjectTypeException $exception) {
echo $exception->getMainMessage().PHP_EOL;
}
try {
v::objectType()->check(0);
} catch (ObjectTypeException $exception) {
echo $exception->getMainMessage().PHP_EOL;
}
?>
--EXPECTF--
"" must be an object
true must be an object
0 must be an object

View file

@ -0,0 +1,26 @@
--FILE--
<?php
require 'vendor/autoload.php';
use Respect\Validation\Validator as v;
v::objectType()->assert(new stdClass);
v::objectType()->check(new stdClass);
?>
--EXPECTF--
--FILE--
<?php
require 'vendor/autoload.php';
use Respect\Validation\Validator as v;
use Respect\Validation\Exceptions\ObjectTypeException;
try {
v::not(v::objectType())->check(new stdClass);
} catch (ObjectTypeException $exception) {
echo $exception->getMainMessage();
}
?>
--EXPECTF--
`[object] (stdClass: { })` must not be an object

View file

@ -0,0 +1,11 @@
--FILE--
<?php
require 'vendor/autoload.php';
use Respect\Validation\Validator as v;
v::not(v::objectType())->check('');
v::not(v::objectType())->check(true);
v::not(v::objectType())->check(0);
?>
--EXPECTF--