2023-05-03 17:51:43 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace Engelsystem\Test\Unit\Http\Validation\Rules;
|
|
|
|
|
|
|
|
use Engelsystem\Http\Validation\Rules\ShirtSize;
|
|
|
|
use Engelsystem\Test\Unit\ServiceProviderTest;
|
|
|
|
|
|
|
|
class ShirtSizeTest extends ServiceProviderTest
|
|
|
|
{
|
|
|
|
private ShirtSize $subject;
|
|
|
|
|
|
|
|
public function setUp(): void
|
|
|
|
{
|
|
|
|
$app = $this->createAndSetUpAppWithConfig([]);
|
|
|
|
$app->get('config')->set('tshirt_sizes', [
|
|
|
|
'S' => 'Small Straight-Cut',
|
|
|
|
'M' => 'Medium Straight-Cut',
|
|
|
|
]);
|
|
|
|
$this->subject = new ShirtSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array<string, array{string, bool}>
|
|
|
|
*/
|
|
|
|
public function provideTestValidateData(): array
|
|
|
|
{
|
2024-03-25 00:03:39 +01:00
|
|
|
return [
|
2023-05-03 17:51:43 +02:00
|
|
|
'empty string' => ['', false],
|
|
|
|
'null' => [null, false],
|
|
|
|
'0' => [0, false],
|
|
|
|
'"S" (known value)' => ['S', true],
|
|
|
|
'"M" (known value)' => ['M', true],
|
|
|
|
'"L" (unknown value)' => ['L', false],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers \Engelsystem\Http\Validation\Rules\ShirtSize::__construct
|
|
|
|
* @dataProvider provideTestValidateData
|
|
|
|
*/
|
|
|
|
public function testValidate(mixed $value, bool $expectedValid): void
|
|
|
|
{
|
|
|
|
self::assertSame($expectedValid, $this->subject->validate($value));
|
|
|
|
}
|
|
|
|
}
|