2019-10-07 21:59:40 +02:00
|
|
|
<?php
|
|
|
|
|
2023-02-03 20:41:59 +01:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2019-10-07 21:59:40 +02:00
|
|
|
namespace Engelsystem\Test\Unit\Http\Validation\Rules;
|
|
|
|
|
|
|
|
use Engelsystem\Http\Validation\Rules\Max;
|
|
|
|
use Engelsystem\Test\Unit\TestCase;
|
|
|
|
|
|
|
|
class MaxTest extends TestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @covers \Engelsystem\Http\Validation\Rules\Max
|
|
|
|
*/
|
2022-12-14 19:15:20 +01:00
|
|
|
public function testValidate(): void
|
2019-10-07 21:59:40 +02:00
|
|
|
{
|
|
|
|
$rule = new Max(3);
|
|
|
|
$this->assertFalse($rule->validate(10));
|
|
|
|
$this->assertFalse($rule->validate('22'));
|
|
|
|
$this->assertTrue($rule->validate(3));
|
2023-09-25 17:16:12 +02:00
|
|
|
$this->assertTrue($rule->validate(2));
|
|
|
|
$this->assertTrue($rule->validate(-10));
|
2019-10-07 21:59:40 +02:00
|
|
|
$this->assertFalse($rule->validate('TEST'));
|
|
|
|
$this->assertTrue($rule->validate('AS'));
|
|
|
|
|
|
|
|
$rule = new Max('2042-01-01');
|
|
|
|
$this->assertFalse($rule->validate('2100-01-01'));
|
2023-09-25 17:16:12 +02:00
|
|
|
$this->assertFalse($rule->validate('2042-01-02'));
|
2019-10-07 21:59:40 +02:00
|
|
|
$this->assertTrue($rule->validate('2000-01-01'));
|
2023-09-25 17:16:12 +02:00
|
|
|
$this->assertTrue($rule->validate('2041-12-31'));
|
|
|
|
$this->assertTrue($rule->validate('2042-01-01'));
|
2019-10-07 21:59:40 +02:00
|
|
|
}
|
|
|
|
}
|