respect-validation/tests/unit/Rules/NumericValTest.php

49 lines
1.1 KiB
PHP
Raw Normal View History

2010-09-27 23:02:30 +02:00
<?php
2015-06-08 16:47:14 +02:00
/*
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
* SPDX-License-Identifier: MIT
*/
declare(strict_types=1);
2010-09-27 23:02:30 +02:00
namespace Respect\Validation\Rules;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use Respect\Validation\Test\RuleTestCase;
2017-11-04 11:21:40 +01:00
#[Group('rule')]
#[CoversClass(NumericVal::class)]
final class NumericValTest extends RuleTestCase
2010-09-27 23:02:30 +02:00
{
/** @return iterable<array{NumericVal, mixed}> */
public static function providerForValidInput(): iterable
2010-09-27 23:02:30 +02:00
{
$numericVal = new NumericVal();
2015-10-18 03:44:47 +02:00
return [
[$numericVal, 164],
[$numericVal, 165.0],
[$numericVal, -165],
[$numericVal, '165'],
[$numericVal, '165.0'],
[$numericVal, '+165.0'],
2015-10-18 03:44:47 +02:00
];
}
/** @return iterable<array{NumericVal, mixed}> */
public static function providerForInvalidInput(): iterable
{
$numericVal = new NumericVal();
2015-10-18 03:44:47 +02:00
return [
[$numericVal, ''],
[$numericVal, null],
[$numericVal, 'a'],
[$numericVal, ' '],
[$numericVal, 'Foo'],
2015-10-18 03:44:47 +02:00
];
2010-09-27 23:02:30 +02:00
}
}