mirror of
https://github.com/Respect/Validation.git
synced 2026-03-15 23:05:45 +01:00
This commit introduces a new feature test: SerializableTest, that tests several validators for their ability to be serialized and unserialized. It also makes it so that the same list of validators can be used by both simple benchmarks and "smoke tests" of all kinds, including this serialize/unserialize one. Additionally, the FilterVar validator was modified. Previously, due to the use of Callback, it was not serializable, but now it is.
20 lines
500 B
PHP
20 lines
500 B
PHP
<?php
|
|
|
|
/*
|
|
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Respect\Validation\Test\SmokeTestProvider;
|
|
|
|
test('Can be serialized and unserialized', function ($validator, $input): void {
|
|
expect(
|
|
unserialize(serialize($validator))->validate($input)->isValid(),
|
|
)->toBeTrue();
|
|
})->with(fn(): Generator => (new class {
|
|
use SmokeTestProvider {
|
|
provideValidatorInput as public __invoke;
|
|
}
|
|
})());
|