mirror of
https://github.com/Respect/Validation.git
synced 2024-06-13 11:12:18 +02:00
ab3732f91f
SPDX IDs are shorter than licensing notes previously used, and adhere better to FOSS standards. It is also machine-readable.
85 lines
2.5 KiB
PHP
85 lines
2.5 KiB
PHP
<?php
|
|
|
|
/*
|
|
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Respect\Validation\Rules;
|
|
|
|
use DateTime;
|
|
use DateTimeImmutable;
|
|
use Respect\Validation\Test\RuleTestCase;
|
|
use Respect\Validation\Test\Stubs\CountableStub;
|
|
|
|
/**
|
|
* @group rule
|
|
*
|
|
* @covers \Respect\Validation\Rules\AbstractComparison
|
|
* @covers \Respect\Validation\Rules\Min
|
|
*
|
|
* @author Alexandre Gomes Gaigalas <alganet@gmail.com>
|
|
* @author Emmerson Siqueira <emmersonsiqueira@gmail.com>
|
|
* @author Gabriel Caruso <carusogabriel34@gmail.com>
|
|
* @author Henrique Moody <henriquemoody@gmail.com>
|
|
*/
|
|
final class MinTest extends RuleTestCase
|
|
{
|
|
/**
|
|
* {@inheritDoc}
|
|
*/
|
|
public function providerForValidInput(): array
|
|
{
|
|
return [
|
|
// From documentation
|
|
[new Min(10), 10],
|
|
[new Min(10), 11],
|
|
[new Min('2010-01-01'), '2010-01-01'],
|
|
[new Min(new DateTime('yesterday')), new DateTimeImmutable('tomorrow')],
|
|
[new Min('1988-09-09'), '18 years ago'],
|
|
[new Min('a'), 'b'],
|
|
|
|
[new Min(100), 165.0],
|
|
[new Min(-100), 200],
|
|
[new Min(200), 200],
|
|
[new Min(200), 300],
|
|
[new Min('a'), 'a'],
|
|
[new Min('a'), 'c'],
|
|
[new Min('yesterday'), 'now'],
|
|
// Samples from issue #178
|
|
[new Min('13-05-2014 03:16'), '20-05-2014 03:16'],
|
|
[new Min(new DateTime('13-05-2014 03:16')), new DateTime('20-05-2014 03:16')],
|
|
[new Min('13-05-2014 03:16'), new DateTime('20-05-2014 03:16')],
|
|
[new Min(new DateTime('13-05-2014 03:16')), '20-05-2014 03:16'],
|
|
[new Min(50), 50],
|
|
[new Min(new CountableStub(10)), 10],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* {@inheritDoc}
|
|
*/
|
|
public function providerForInvalidInput(): array
|
|
{
|
|
return [
|
|
// From documentation
|
|
[new Min(10), 9],
|
|
[new Min('2011-01-01'), '2009-01-01'],
|
|
[new Min(new DateTimeImmutable('+1 month')), new DateTime('today')],
|
|
[new Min('+1 minute'), new DateTime('now')],
|
|
[new Min('C'), 'A'],
|
|
|
|
[new Min(100), ''],
|
|
[new Min(100), ''],
|
|
[new Min(500), 300],
|
|
[new Min(0), -250],
|
|
[new Min(0), -50],
|
|
[new Min(new CountableStub(1)), 0],
|
|
[new Min(2040), '2018-01-25'],
|
|
[new Min(10.5), '2018-01-25'],
|
|
];
|
|
}
|
|
}
|