engelsystem/tests/Unit/Http/Validation/Rules/MaxTest.php

34 lines
1.0 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
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
*/
public function testValidate(): void
{
$rule = new Max(3);
$this->assertFalse($rule->validate(10));
$this->assertFalse($rule->validate('22'));
$this->assertTrue($rule->validate(3));
$this->assertTrue($rule->validate(2));
$this->assertTrue($rule->validate(-10));
$this->assertFalse($rule->validate('TEST'));
$this->assertTrue($rule->validate('AS'));
$rule = new Max('2042-01-01');
$this->assertFalse($rule->validate('2100-01-01'));
$this->assertFalse($rule->validate('2042-01-02'));
$this->assertTrue($rule->validate('2000-01-01'));
$this->assertTrue($rule->validate('2041-12-31'));
$this->assertTrue($rule->validate('2042-01-01'));
}
}