2010-11-09 01:37:50 +01: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-11-09 01:37:50 +01:00
|
|
|
namespace Respect\Validation\Rules;
|
|
|
|
|
2018-08-08 02:15:30 +02:00
|
|
|
use ArrayIterator;
|
|
|
|
use ArrayObject;
|
|
|
|
use DateTime;
|
2024-01-28 01:46:21 +01:00
|
|
|
use PHPUnit\Framework\Attributes\CoversClass;
|
|
|
|
use PHPUnit\Framework\Attributes\Group;
|
2018-08-08 02:15:30 +02:00
|
|
|
use Respect\Validation\Test\RuleTestCase;
|
|
|
|
use SplFileInfo;
|
|
|
|
use stdClass;
|
|
|
|
use Traversable;
|
2017-11-04 11:21:40 +01:00
|
|
|
|
2024-01-28 01:46:21 +01:00
|
|
|
#[Group('rule')]
|
|
|
|
#[CoversClass(Instance::class)]
|
2018-08-08 02:15:30 +02:00
|
|
|
final class InstanceTest extends RuleTestCase
|
2010-11-09 01:37:50 +01:00
|
|
|
{
|
2024-02-04 19:23:04 +01:00
|
|
|
/** @return iterable<array{Instance, mixed}> */
|
|
|
|
public static function providerForValidInput(): iterable
|
2010-11-09 01:37:50 +01:00
|
|
|
{
|
2018-08-08 02:15:30 +02:00
|
|
|
return [
|
|
|
|
[new Instance(DateTime::class), new DateTime()],
|
|
|
|
[new Instance(Traversable::class), new ArrayObject()],
|
|
|
|
[new Instance(ArrayIterator::class), new ArrayIterator()],
|
|
|
|
];
|
2010-11-09 01:37:50 +01:00
|
|
|
}
|
|
|
|
|
2024-02-04 19:23:04 +01:00
|
|
|
/** @return iterable<array{Instance, mixed}> */
|
|
|
|
public static function providerForInvalidInput(): iterable
|
2010-11-09 01:37:50 +01:00
|
|
|
{
|
2018-08-08 02:15:30 +02:00
|
|
|
return [
|
|
|
|
[new Instance(DateTime::class), ''],
|
|
|
|
[new Instance(Traversable::class), null],
|
|
|
|
[new Instance(SplFileInfo::class), new stdClass()],
|
|
|
|
];
|
2010-11-09 01:37:50 +01:00
|
|
|
}
|
2013-01-14 23:44:49 +01:00
|
|
|
}
|