mirror of
https://github.com/Respect/Validation.git
synced 2026-03-17 07:45:45 +01:00
49 lines
1.3 KiB
PHP
49 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;
|
|
use stdClass;
|
|
|
|
#[Group('rule')]
|
|
#[CoversClass(Luhn::class)]
|
|
final class LuhnTest extends RuleTestCase
|
|
{
|
|
/** @return iterable<array{Luhn, mixed}> */
|
|
public static function providerForValidInput(): iterable
|
|
{
|
|
$rule = new Luhn();
|
|
|
|
return [
|
|
'17 digits string' => [$rule, '2222400041240011'],
|
|
'16 digits string' => [$rule, '340316193809364'],
|
|
'integer' => [$rule, 6011000990139424],
|
|
];
|
|
}
|
|
|
|
/** @return iterable<array{Luhn, mixed}> */
|
|
public static function providerForInvalidInput(): iterable
|
|
{
|
|
$rule = new Luhn();
|
|
|
|
return [
|
|
'invalid string' => [$rule, '2222400041240021'],
|
|
'invalid integer' => [$rule, 340316193809334],
|
|
'float' => [$rule, 222240004124001.1],
|
|
'boolean true' => [$rule, true],
|
|
'boolean false' => [$rule, false],
|
|
'empty' => [$rule, ''],
|
|
'object' => [$rule, new stdClass()],
|
|
'array' => [$rule, [2222400041240011]],
|
|
];
|
|
}
|
|
}
|