respect-validation/tests/integration/rules/resourceType.phpt
Henrique Moody f53b77a186
Add support for PHP 8.0
We already supported PHP 8.0 as our constrains in the "composer.json"
file was ">=7.3", but we were not testing it before.

Because of that, I found a bug on "EndsWith" which is fixed now.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2020-08-28 08:53:41 +02:00

43 lines
1 KiB
PHP

--CREDITS--
Henrique Moody <henriquemoody@gmail.com>
--FILE--
<?php
declare(strict_types=1);
require 'vendor/autoload.php';
use Respect\Validation\Exceptions\NestedValidationException;
use Respect\Validation\Exceptions\ResourceTypeException;
use Respect\Validation\Validator as v;
try {
v::resourceType()->check('test');
} catch (ResourceTypeException $exception) {
echo $exception->getMessage() . PHP_EOL;
}
try {
v::not(v::resourceType())->check(tmpfile());
} catch (ResourceTypeException $exception) {
echo $exception->getMessage() . PHP_EOL;
}
try {
v::resourceType()->assert([]);
} catch (NestedValidationException $exception) {
echo $exception->getFullMessage() . PHP_EOL;
}
try {
v::not(v::resourceType())->assert(tmpfile());
} catch (NestedValidationException $exception) {
echo $exception->getFullMessage() . PHP_EOL;
}
?>
--EXPECT--
"test" must be a resource
`[resource] (stream)` must not be a resource
- `{ }` must be a resource
- `[resource] (stream)` must not be a resource