respect-validation/tests/unit/Rules/MaxAgeTest.php
Henrique Moody 3145426472
Update version of "respect/coding-standard"
With that update, we will be fully following PSR-12.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2020-07-21 22:54:41 +02:00

71 lines
2.1 KiB
PHP

<?php
/*
* This file is part of Respect/Validation.
*
* (c) Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Rules;
use DateTime;
use DateTimeImmutable;
use Respect\Validation\Test\RuleTestCase;
use stdClass;
use function date;
use function strtotime;
/**
* @group rule
*
* @covers \Respect\Validation\Rules\AbstractAge
* @covers \Respect\Validation\Rules\MaxAge
*
* @author Emmerson Siqueira <emmersonsiqueira@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class MaxAgeTest extends RuleTestCase
{
/**
* {@inheritDoc}
*/
public function providerForValidInput(): array
{
return [
[new MaxAge(30, 'Y-m-d'), date('Y-m-d', strtotime('30 years ago'))],
[new MaxAge(30, 'Y-m-d'), date('Y-m-d', strtotime('29 years ago'))],
[new MaxAge(30), '30 years ago'],
[new MaxAge(30), '29 years ago'],
];
}
/**
* {@inheritDoc}
*/
public function providerForInvalidInput(): array
{
return [
[new MaxAge(30), new DateTime('30 years ago')],
[new MaxAge(30), new DateTime('29 years ago')],
[new MaxAge(30), new DateTimeImmutable('30 years ago')],
[new MaxAge(30), new DateTimeImmutable('29 years ago')],
[new MaxAge(30, 'Y-m-d'), new DateTime('30 years ago')],
[new MaxAge(30, 'Y-m-d'), new DateTimeImmutable('30 years ago')],
[new MaxAge(30, 'Y-m-d'), '30 years ago'],
[new MaxAge(30, 'Y-m-d'), date('Y/m/d', strtotime('30 years ago'))],
[new MaxAge(30), new DateTime('31 years ago')],
[new MaxAge(30), new DateTimeImmutable('31 years ago')],
[new MaxAge(30), '31 years ago'],
[new MaxAge(30, 'Y-m-d'), date('Y-m-d', strtotime('31 years ago'))],
[new MaxAge(30), 'invalid-input'],
[new MaxAge(30), new stdClass()],
];
}
}