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

56 lines
1.2 KiB
PHP
Raw Normal View History

2015-08-20 06:02:11 +02:00
<?php
/*
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
* SPDX-License-Identifier: MIT
2015-08-20 06:02:11 +02:00
*/
declare(strict_types=1);
2015-08-20 06:02:11 +02:00
namespace Respect\Validation\Rules;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use Respect\Validation\Test\RuleTestCase;
use stdClass;
use function tmpfile;
2017-11-04 11:21:40 +01:00
#[Group('rule')]
#[CoversClass(ScalarVal::class)]
final class ScalarValTest extends RuleTestCase
2015-08-20 06:02:11 +02:00
{
/** @return iterable<array{ScalarVal, mixed}> */
public static function providerForValidInput(): iterable
2015-08-20 06:02:11 +02:00
{
$rule = new ScalarVal();
2015-08-20 06:02:11 +02:00
return [
[$rule, '6'],
[$rule, 'String'],
[$rule, 1.0],
[$rule, 42],
[$rule, false],
[$rule, true],
];
2015-08-20 06:02:11 +02:00
}
/** @return iterable<array{ScalarVal, mixed}> */
public static function providerForInvalidInput(): iterable
2015-08-20 06:02:11 +02:00
{
$rule = new ScalarVal();
2015-08-20 06:02:11 +02:00
2015-10-18 03:44:47 +02:00
return [
[$rule, []],
[
$rule,
static function (): void {
},
],
[$rule, new stdClass()],
[$rule, null],
[$rule, tmpfile()],
2015-10-18 03:44:47 +02:00
];
2015-08-20 06:02:11 +02:00
}
}