2015-08-20 06:02:11 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
2023-02-17 05:13:51 +01:00
|
|
|
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
|
|
|
|
* SPDX-License-Identifier: MIT
|
2015-08-20 06:02:11 +02:00
|
|
|
*/
|
|
|
|
|
2017-11-19 19:01:31 +01:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2015-08-20 06:02:11 +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-03-09 15:06:57 +01:00
|
|
|
use Respect\Validation\Test\RuleTestCase;
|
2019-02-09 13:48:17 +01:00
|
|
|
use stdClass;
|
2020-07-21 22:54:41 +02:00
|
|
|
|
2019-02-17 19:41:55 +01:00
|
|
|
use function tmpfile;
|
2017-11-04 11:21:40 +01:00
|
|
|
|
2024-01-28 01:46:21 +01:00
|
|
|
#[Group('rule')]
|
|
|
|
#[CoversClass(ScalarVal::class)]
|
2018-03-09 15:06:57 +01:00
|
|
|
final class ScalarValTest extends RuleTestCase
|
2015-08-20 06:02:11 +02:00
|
|
|
{
|
2024-02-04 19:23:04 +01:00
|
|
|
/** @return iterable<array{ScalarVal, mixed}> */
|
|
|
|
public static function providerForValidInput(): iterable
|
2015-08-20 06:02:11 +02:00
|
|
|
{
|
2018-03-09 15:06:57 +01:00
|
|
|
$rule = new ScalarVal();
|
2015-08-20 06:02:11 +02:00
|
|
|
|
2018-03-09 15:06:57 +01:00
|
|
|
return [
|
|
|
|
[$rule, '6'],
|
|
|
|
[$rule, 'String'],
|
|
|
|
[$rule, 1.0],
|
|
|
|
[$rule, 42],
|
|
|
|
[$rule, false],
|
|
|
|
[$rule, true],
|
|
|
|
];
|
2015-08-20 06:02:11 +02:00
|
|
|
}
|
|
|
|
|
2024-02-04 19:23:04 +01:00
|
|
|
/** @return iterable<array{ScalarVal, mixed}> */
|
|
|
|
public static function providerForInvalidInput(): iterable
|
2015-08-20 06:02:11 +02:00
|
|
|
{
|
2018-03-09 15:06:57 +01:00
|
|
|
$rule = new ScalarVal();
|
2015-08-20 06:02:11 +02:00
|
|
|
|
2015-10-18 03:44:47 +02:00
|
|
|
return [
|
2018-03-09 15:06:57 +01:00
|
|
|
[$rule, []],
|
2019-02-07 19:45:57 +01:00
|
|
|
[
|
|
|
|
$rule,
|
2019-02-09 12:31:09 +01:00
|
|
|
static function (): void {
|
2019-02-09 12:57:50 +01:00
|
|
|
},
|
2019-02-07 19:45:57 +01:00
|
|
|
],
|
2019-02-09 13:48:17 +01:00
|
|
|
[$rule, new stdClass()],
|
2018-03-09 15:06:57 +01:00
|
|
|
[$rule, null],
|
|
|
|
[$rule, tmpfile()],
|
2015-10-18 03:44:47 +02:00
|
|
|
];
|
2015-08-20 06:02:11 +02:00
|
|
|
}
|
|
|
|
}
|