mirror of
https://github.com/Respect/Validation.git
synced 2024-06-26 17:20:16 +02:00
56 lines
1.2 KiB
PHP
56 lines
1.2 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;
|
|
|
|
use function tmpfile;
|
|
|
|
#[Group('rule')]
|
|
#[CoversClass(ScalarVal::class)]
|
|
final class ScalarValTest extends RuleTestCase
|
|
{
|
|
/** @return iterable<array{ScalarVal, mixed}> */
|
|
public static function providerForValidInput(): iterable
|
|
{
|
|
$rule = new ScalarVal();
|
|
|
|
return [
|
|
[$rule, '6'],
|
|
[$rule, 'String'],
|
|
[$rule, 1.0],
|
|
[$rule, 42],
|
|
[$rule, false],
|
|
[$rule, true],
|
|
];
|
|
}
|
|
|
|
/** @return iterable<array{ScalarVal, mixed}> */
|
|
public static function providerForInvalidInput(): iterable
|
|
{
|
|
$rule = new ScalarVal();
|
|
|
|
return [
|
|
[$rule, []],
|
|
[
|
|
$rule,
|
|
static function (): void {
|
|
},
|
|
],
|
|
[$rule, new stdClass()],
|
|
[$rule, null],
|
|
[$rule, tmpfile()],
|
|
];
|
|
}
|
|
}
|