2026-08-13 12:10:53 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace Tests\Unit\Domain\Models\ValueObjects;
|
|
|
|
|
|
|
|
|
|
use Domain\Models\ValueObjects\EstablishmentCode;
|
|
|
|
|
|
|
|
|
|
covers(EstablishmentCode::class);
|
|
|
|
|
|
2026-08-14 11:33:05 +02:00
|
|
|
describe('EstablishmentCode Value Object Instantiation', function (): void {
|
2026-08-13 12:10:53 +02:00
|
|
|
it('accepts valid establishment codes matching pattern', function (string $input): void {
|
|
|
|
|
// GIVEN
|
|
|
|
|
$value = $input;
|
|
|
|
|
|
|
|
|
|
// WHEN
|
|
|
|
|
$establishmentCode = new EstablishmentCode($value);
|
|
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
|
expect($establishmentCode->value)->toBe($value);
|
|
|
|
|
})->with(['EST01', '01', 'ESTABLISHMENT', 'A1']);
|
2026-08-14 11:33:05 +02:00
|
|
|
});
|
2026-08-13 12:10:53 +02:00
|
|
|
|
2026-08-14 11:33:05 +02:00
|
|
|
describe('EstablishmentCode Value Object Domain Rules', function (): void {
|
2026-08-13 12:10:53 +02:00
|
|
|
it('rejects invalid, lowercase, short or empty establishment codes', function (string $invalid): void {
|
|
|
|
|
// GIVEN / WHEN / THEN
|
|
|
|
|
expect(fn () => new EstablishmentCode($invalid))
|
|
|
|
|
->toThrow(\DomainException::class);
|
|
|
|
|
})->with(['est01', 'A', '', 'EST 01', 'EST-01']);
|
|
|
|
|
});
|