mirror of
https://github.com/Respect/Validation.git
synced 2026-03-18 08:09:51 +01:00
Also updates how the tests define the name of the instance by using the class keyword [1] instead of a string with the class. That is useful in code analyses be able to identify the usage of these classes/interfaces. [1] http://php.net/class#language.oop5.basic.class.class Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
37 lines
1.1 KiB
PHP
37 lines
1.1 KiB
PHP
--FILE--
|
|
<?php
|
|
require 'vendor/autoload.php';
|
|
|
|
use Respect\Validation\Exceptions\InstanceException;
|
|
use Respect\Validation\Exceptions\NestedValidationException;
|
|
use Respect\Validation\Validator as v;
|
|
|
|
try {
|
|
v::instance(DateTime::class)->check('');
|
|
} catch (InstanceException $exception) {
|
|
echo $exception->getMessage().PHP_EOL;
|
|
}
|
|
|
|
try {
|
|
v::not(v::instance(Traversable::class))->check(new \ArrayObject());
|
|
} catch (InstanceException $exception) {
|
|
echo $exception->getMessage().PHP_EOL;
|
|
}
|
|
|
|
try {
|
|
v::instance(ArrayIterator::class)->assert(new stdClass());
|
|
} catch (NestedValidationException $exception) {
|
|
echo $exception->getFullMessage().PHP_EOL;
|
|
}
|
|
|
|
try {
|
|
v::not(v::instance(stdClass::class))->assert(new stdClass());
|
|
} catch (NestedValidationException $exception) {
|
|
echo $exception->getFullMessage().PHP_EOL;
|
|
}
|
|
?>
|
|
--EXPECTF--
|
|
"" must be an instance of "DateTime"
|
|
`[traversable] (ArrayObject: { })` must not be an instance of "Traversable"
|
|
- `[object] (stdClass: { })` must be an instance of "ArrayIterator"
|
|
- `[object] (stdClass: { })` must not be an instance of "stdClass"
|