respect-validation/tests/unit/Rules/AnyOfTest.php
Henrique Moody df16ddaf48
Improve composite-based rules
Because the rules' property is read-only, there aren't many reasons not
to expose that, especially since we already expose the rules anyways.

I also changed the implementation of "OneOf" because we don't see "xor"
enough these days.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2024-03-06 18:02:39 +01:00

37 lines
1.3 KiB
PHP

<?php
/*
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
* SPDX-License-Identifier: MIT
*/
declare(strict_types=1);
namespace Respect\Validation\Rules;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use Respect\Validation\Test\Rules\Stub;
use Respect\Validation\Test\RuleTestCase;
#[Group('rule')]
#[CoversClass(AnyOf::class)]
final class AnyOfTest extends RuleTestCase
{
/** @return iterable<string, array{AnyOf, mixed}> */
public static function providerForValidInput(): iterable
{
yield 'fail, pass' => [new AnyOf(Stub::fail(1), Stub::pass(1)), []];
yield 'pass, fail' => [new AnyOf(Stub::pass(1), Stub::fail(1)), []];
yield 'fail, fail, pass' => [new AnyOf(Stub::fail(1), Stub::fail(1), Stub::pass(1)), []];
yield 'fail, pass, fail' => [new AnyOf(Stub::fail(1), Stub::pass(1), Stub::fail(1)), []];
yield 'pass, fail, fail' => [new AnyOf(Stub::pass(1), Stub::fail(1), Stub::fail(1)), []];
}
/** @return iterable<string, array{AnyOf, mixed}> */
public static function providerForInvalidInput(): iterable
{
yield 'fail, fail' => [new AnyOf(Stub::fail(1), Stub::fail(1)), []];
yield 'fail, fail, fail' => [new AnyOf(Stub::fail(1), Stub::fail(1), Stub::fail(1)), []];
}
}