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