respect-validation/tests/benchmark/ValidatorBench.php
Alexandre Gomes Gaigalas 0090191aaa Introduce tests for serialization of validators
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.
2026-01-19 09:24:38 +00:00

30 lines
661 B
PHP

<?php
/*
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
* SPDX-License-Identifier: MIT
*/
declare(strict_types=1);
namespace Respect\Validation\Benchmarks;
use PhpBench\Attributes as Bench;
use Respect\Validation\Test\SmokeTestProvider;
use Respect\Validation\Validator;
class ValidatorBench
{
use SmokeTestProvider;
/** @param array<Validator, mixed> $params */
#[Bench\Iterations(10)]
#[Bench\RetryThreshold(10)]
#[Bench\Revs(5)]
#[Bench\ParamProviders(['provideValidatorInput'])]
public function benchValidate(array $params): void
{
[$v, $input] = $params;
$v->validate($input);
}
}