respect-validation/tests/unit/Rules/XdigitTest.php
Henrique Moody 692d317cbe
Update the validation engine of filter-based rules
While I migrate them, I also renamed "AbstractFilterRule" to "Filter"
because that's a much simpler name, and I would like to stop having
"Abstract" and "Interfaces" as part of the name of the classes.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2024-02-22 17:21:49 +01:00

47 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\RuleTestCase;
#[Group('rule')]
#[CoversClass(Xdigit::class)]
final class XdigitTest extends RuleTestCase
{
/** @return iterable<array{Xdigit, mixed}> */
public static function providerForValidInput(): iterable
{
return [
[new Xdigit(), 'FFF'],
[new Xdigit(), '15'],
[new Xdigit(), 'DE12FA'],
[new Xdigit(), '1234567890abcdef'],
[new Xdigit(), 443],
[new Xdigit(), 0x123],
[new Xdigit('!@#$%^&*(){} '), '!@#$%^&*(){} abc 123'],
[new Xdigit("[]?+=/\\-_|\"',<>. \t\n"), "[]?+=/\\-_|\"',<>. \t \n abc 123"],
];
}
/** @return iterable<array{Xdigit, mixed}> */
public static function providerForInvalidInput(): iterable
{
return [
[new Xdigit(), ''],
[new Xdigit(), null],
[new Xdigit(), 'j'],
[new Xdigit(), ' '],
[new Xdigit(), 'Foo'],
[new Xdigit(), '1.5'],
];
}
}