2019-10-07 21:59:40 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Engelsystem\Test\Unit\Http\Validation\Rules;
|
|
|
|
|
|
|
|
use Engelsystem\Test\Unit\Http\Validation\Rules\Stub\UsesStringInputLength;
|
|
|
|
use Engelsystem\Test\Unit\TestCase;
|
|
|
|
|
|
|
|
class StringInputLengthTest extends TestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @covers \Engelsystem\Http\Validation\Rules\StringInputLength::validate
|
|
|
|
* @covers \Engelsystem\Http\Validation\Rules\StringInputLength::isDateTime
|
|
|
|
* @dataProvider validateProvider
|
|
|
|
*/
|
2022-12-14 19:15:20 +01:00
|
|
|
public function testValidate(mixed $input, mixed $expectedInput): void
|
2019-10-07 21:59:40 +02:00
|
|
|
{
|
|
|
|
$rule = new UsesStringInputLength();
|
|
|
|
$rule->validate($input);
|
|
|
|
|
|
|
|
$this->assertEquals($expectedInput, $rule->lastInput);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array[]
|
|
|
|
*/
|
2022-12-14 19:15:20 +01:00
|
|
|
public function validateProvider(): array
|
2019-10-07 21:59:40 +02:00
|
|
|
{
|
|
|
|
return [
|
|
|
|
['TEST', 4],
|
|
|
|
['?', 1],
|
|
|
|
['2042-01-01 00:00', '2042-01-01 00:00'],
|
2023-01-21 01:41:55 +01:00
|
|
|
['2042-01-01', '2042-01-01'],
|
|
|
|
['12:42', '12:42'],
|
2019-10-07 21:59:40 +02:00
|
|
|
['3', '3'],
|
2023-01-21 01:41:55 +01:00
|
|
|
['...', 3],
|
|
|
|
['Test Tester', 11],
|
|
|
|
['com', 3],
|
2019-10-07 21:59:40 +02:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|