2011-10-18 01:45:31 +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);
|
|
|
|
|
2011-10-18 01:45:31 +02:00
|
|
|
namespace Respect\Validation\Rules;
|
|
|
|
|
|
|
|
use DateTime;
|
2024-01-28 01:46:21 +01:00
|
|
|
use PHPUnit\Framework\Attributes\CoversClass;
|
|
|
|
use PHPUnit\Framework\Attributes\Group;
|
2018-09-07 18:28:42 +02:00
|
|
|
use Respect\Validation\Test\RuleTestCase;
|
2011-10-18 01:45:31 +02:00
|
|
|
|
2024-01-28 01:46:21 +01:00
|
|
|
#[Group('rule')]
|
|
|
|
#[CoversClass(LeapDate::class)]
|
2018-09-07 18:28:42 +02:00
|
|
|
final class LeapDateTest extends RuleTestCase
|
2011-10-18 01:45:31 +02:00
|
|
|
{
|
2024-02-04 19:23:04 +01:00
|
|
|
/** @return iterable<array{LeapDate, mixed}> */
|
|
|
|
public static function providerForValidInput(): iterable
|
2011-10-18 14:51:32 +02:00
|
|
|
{
|
2018-09-07 18:28:42 +02:00
|
|
|
return [
|
|
|
|
[new LeapDate('Y-m-d'), '1988-02-29'],
|
|
|
|
[new LeapDate('Y-m-d'), '1992-02-29'],
|
|
|
|
[new LeapDate('Y-m-d'), new DateTime('1988-02-29')],
|
|
|
|
[new LeapDate('Y-m-d'), new DateTime('1992-02-29')],
|
|
|
|
];
|
2011-10-18 14:51:32 +02:00
|
|
|
}
|
2017-11-19 19:01:31 +01:00
|
|
|
|
2024-02-04 19:23:04 +01:00
|
|
|
/** @return iterable<array{LeapDate, mixed}> */
|
|
|
|
public static function providerForInvalidInput(): iterable
|
2011-11-29 22:20:07 +01:00
|
|
|
{
|
2018-09-07 18:28:42 +02:00
|
|
|
return [
|
|
|
|
[new LeapDate('Y-m-d'), '1989-02-29'],
|
|
|
|
[new LeapDate('Y-m-d'), '1993-02-29'],
|
|
|
|
[new LeapDate('Y-m-d'), new DateTime('1989-02-29')],
|
|
|
|
[new LeapDate('Y-m-d'), new DateTime('1993-02-29')],
|
|
|
|
[new LeapDate('Y-m-d'), []],
|
|
|
|
];
|
2011-11-29 22:20:07 +01:00
|
|
|
}
|
2011-10-18 01:45:31 +02:00
|
|
|
}
|