2026-09-22 12:45:08 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace Tests\Unit\Domain\Models\ValueObjects;
|
|
|
|
|
|
|
|
|
|
use Domain\Enums\BarcodeFormat;
|
|
|
|
|
use Domain\Models\ValueObjects\GS1;
|
|
|
|
|
|
|
|
|
|
covers(GS1::class);
|
|
|
|
|
|
|
|
|
|
describe('gs1', function (): void {
|
|
|
|
|
it('creates a valid gs1', function (): void {
|
|
|
|
|
// GIVEN
|
2026-09-23 09:24:18 +02:00
|
|
|
$value = '1010100101';
|
2026-09-22 12:45:08 +02:00
|
|
|
$format = BarcodeFormat::EAN13;
|
|
|
|
|
|
|
|
|
|
// WHEN
|
|
|
|
|
$GS1 = new GS1($value, $format);
|
|
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
|
expect($GS1->value)->toBe($value)
|
|
|
|
|
->and($GS1->format)->toBe($format);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('rejects invalid gs1', function (): void {
|
|
|
|
|
// GIVEN
|
2026-09-23 09:24:18 +02:00
|
|
|
$value = '';
|
2026-09-22 12:45:08 +02:00
|
|
|
$format = BarcodeFormat::EAN13;
|
|
|
|
|
|
|
|
|
|
// GIVEN / THEN
|
|
|
|
|
expect(fn (): GS1 => new GS1($value, $format))->toThrow(\DomainException::class);
|
|
|
|
|
});
|
|
|
|
|
});
|