mirror of
https://github.com/Respect/Validation.git
synced 2024-06-13 19:22:16 +02:00
Create integration tests for "ObjectType" rule
This commit is contained in:
parent
cbbf082c15
commit
6fb15a697c
10
tests/integration/objectType_1.phpt
Normal file
10
tests/integration/objectType_1.phpt
Normal 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--
|
29
tests/integration/objectType_2.phpt
Normal file
29
tests/integration/objectType_2.phpt
Normal 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
|
26
tests/integration/objectType_3.phpt
Normal file
26
tests/integration/objectType_3.phpt
Normal 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
|
11
tests/integration/objectType_4.phpt
Normal file
11
tests/integration/objectType_4.phpt
Normal 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--
|
Loading…
Reference in a new issue