respect-validation/tests/unit/Validators/AlnumTest.php
Henrique Moody 7c681fec66
Fix SPDX headers in all files
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.
2026-02-03 15:23:23 +01:00

68 lines
2.2 KiB
PHP

<?php
/*
* SPDX-License-Identifier: MIT
* SPDX-FileCopyrightText: (c) Respect Project Contributors
* SPDX-FileContributor: Alexandre Gomes Gaigalas <alganet@gmail.com>
* SPDX-FileContributor: Gabriel Caruso <carusogabriel34@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 stdClass;
#[Group('validator')]
#[CoversClass(Alnum::class)]
final class AlnumTest extends RuleTestCase
{
/** @return iterable<array{Alnum, mixed}> */
public static function providerForValidInput(): iterable
{
return [
[new Alnum(), 'alganet'],
[new Alnum('- ! :'), 'foo :- 123 !'],
[new Alnum('0-9'), '0alg-anet0'],
[new Alnum(), '1'],
[new Alnum(), 'a'],
[new Alnum(), 'foobar'],
[new Alnum('_'), 'rubinho_'],
[new Alnum('.'), 'google.com'],
[new Alnum(' '), 'alganet alganet'],
[new Alnum(), 0],
[new Alnum('!@#$%^&*(){}'), '!@#$%^&*(){}abc123'],
[new Alnum('[]?+=/\\-_|"\',<>.'), '[]?+=/\\-_|"\',<>.abc123'],
[new Alnum("[]?+=/\\-_|\"',<>. \t\n"), "abc[]?+=/\\-_|\"',<>. \t\n123"],
[new Alnum('-', '*'), 'a-1*d'],
];
}
/** @return iterable<array{Alnum, mixed}> */
public static function providerForInvalidInput(): iterable
{
return [
[new Alnum(), ''],
[new Alnum(), 'number 100%'],
[new Alnum('%'), 'number 100%'],
[new Alnum(), '@#$'],
[new Alnum(), '_'],
[new Alnum(), 'dgç'],
[new Alnum(), 1e21],
[new Alnum(), null],
[new Alnum(), new stdClass()],
[new Alnum(), []],
[new Alnum('%'), 'number 100%'],
[new Alnum(), "\t"],
[new Alnum(), "\n"],
[new Alnum(), "\nabc"],
[new Alnum(), "\tdef"],
[new Alnum(), "\nabc \t"],
[new Alnum(), 'alganet alganet'],
];
}
}