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.
60 lines
2.2 KiB
PHP
60 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;
|
|
|
|
#[Group('validator')]
|
|
#[CoversClass(Digit::class)]
|
|
final class DigitTest extends RuleTestCase
|
|
{
|
|
/** @return iterable<array{Digit, mixed}> */
|
|
public static function providerForValidInput(): iterable
|
|
{
|
|
return [
|
|
'positive integer' => [new Digit(), 165],
|
|
'positive string-integer' => [new Digit(), '01650'],
|
|
'positive string-integer with one exception' => [new Digit('-'), '16-50'],
|
|
'positive string-integer with multiple exceptions' => [new Digit('.-'), '16-5.0'],
|
|
'only exceptions' => [new Digit('!@#$%^&*(){}'), '!@#$%^&*(){}'],
|
|
'multiple exceptions' => [new Digit('.', '-'), '012.071.070-69'],
|
|
'float' => [new Digit(), 1.0],
|
|
'boolean true' => [new Digit(), true],
|
|
'octal' => [new Digit(), 01],
|
|
'string-octal' => [new Digit(), '01'],
|
|
];
|
|
}
|
|
|
|
/** @return iterable<array{Digit, mixed}> */
|
|
public static function providerForInvalidInput(): iterable
|
|
{
|
|
return [
|
|
'empty' => [new Digit(), ''],
|
|
'with spaces' => [new Digit(), '16 50'],
|
|
'with tabs' => [new Digit(), "1\t1"],
|
|
'with newlines' => [new Digit(), "1\n1"],
|
|
'null' => [new Digit(), null],
|
|
'with non-numeric' => [new Digit(), '16-50'],
|
|
'alphabetic' => [new Digit(), 'a'],
|
|
'alphanumeric' => [new Digit(), 'a1'],
|
|
'negative integer' => [new Digit(), -12],
|
|
'negative string-integer' => [new Digit(), '-12'],
|
|
'float-string' => [new Digit(), '1.0'],
|
|
'negative float' => [new Digit(), -1.1],
|
|
'negative string-float' => [new Digit(), '-1.1'],
|
|
'boolean false' => [new Digit(), false],
|
|
];
|
|
}
|
|
}
|