mirror of
https://github.com/Respect/Validation.git
synced 2026-03-18 08:09:51 +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.
30 lines
661 B
PHP
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);
|
|
}
|
|
}
|