mirror of
https://github.com/Respect/Validation.git
synced 2026-03-15 06:45:44 +01:00
I ran the `bin/console spdx --fix` with different strategies for different files. For most of the core classes, since they've been drastically rebuilt, I've run it with the `git-blame` strategy, for for the `src/Validators`, in which the API changed completely but the logic remains the same, I use the `git-log` strategy.
45 lines
1.5 KiB
PHP
45 lines
1.5 KiB
PHP
<?php
|
|
|
|
/*
|
|
* SPDX-License-Identifier: MIT
|
|
* SPDX-FileCopyrightText: (c) Respect Project Contributors
|
|
* SPDX-FileContributor: Alexandre Gomes Gaigalas <alganet@gmail.com>
|
|
* SPDX-FileContributor: Danilo Correa <danilosilva87@gmail.com>
|
|
* SPDX-FileContributor: Henrique Moody <henriquemoody@gmail.com>
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Respect\Validation\Validators;
|
|
|
|
use PHPUnit\Framework\Attributes\CoversClass;
|
|
use PHPUnit\Framework\Attributes\Group;
|
|
use Respect\Validation\Test\RuleTestCase;
|
|
use Respect\Validation\Test\Validators\Stub;
|
|
|
|
use function rand;
|
|
|
|
#[Group('validator')]
|
|
#[CoversClass(When::class)]
|
|
final class WhenTest extends RuleTestCase
|
|
{
|
|
/** @return array<array{When, mixed}> */
|
|
public static function providerForValidInput(): array
|
|
{
|
|
return [
|
|
'when fail, then pass' => [new When(Stub::pass(1), Stub::pass(1)), rand()],
|
|
'when pass, then pass, else daze' => [new When(Stub::pass(1), Stub::pass(1), Stub::daze()), rand()],
|
|
'when fail, then daze, else pass' => [new When(Stub::fail(1), Stub::daze(), Stub::pass(1)), rand()],
|
|
];
|
|
}
|
|
|
|
/** @return array<array{When, mixed}> */
|
|
public static function providerForInvalidInput(): array
|
|
{
|
|
return [
|
|
'when pass, then fail' => [new When(Stub::pass(1), Stub::fail(1)), rand()],
|
|
'when pass, then fail, else daze' => [new When(Stub::pass(1), Stub::fail(1), Stub::daze()), rand()],
|
|
'when fail, then daze, else fail' => [new When(Stub::fail(1), Stub::daze(), Stub::fail(1)), rand()],
|
|
];
|
|
}
|
|
}
|