2026-08-14 11:33:05 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2026-08-14 15:38:10 +02:00
|
|
|
namespace Tests\Unit\Domain\Models\ValueObjects\Inco\Composition;
|
2026-08-14 11:33:05 +02:00
|
|
|
|
2026-08-14 15:38:10 +02:00
|
|
|
use Domain\Models\ValueObjects\Inco\Composition\Identification;
|
2026-08-14 11:33:05 +02:00
|
|
|
|
|
|
|
|
covers(Identification::class);
|
|
|
|
|
|
|
|
|
|
describe('Identification Value Object Instantiation', function (): void {
|
|
|
|
|
it('instantiates valid Identification VO', function (): void {
|
|
|
|
|
// GIVEN
|
|
|
|
|
$name = 'Poulet Rôti 1kg';
|
|
|
|
|
$number = '12345';
|
|
|
|
|
$source = 'LDC';
|
|
|
|
|
|
|
|
|
|
// WHEN
|
|
|
|
|
$identification = new Identification($name, $number, $source);
|
|
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
|
expect($identification->name)->toBe('Poulet Rôti 1kg')
|
|
|
|
|
->and($identification->number)->toBe('12345')
|
|
|
|
|
->and($identification->source)->toBe('LDC');
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('Identification Value Object Domain Rules', function (): void {
|
|
|
|
|
it('throws DomainException when name is empty', function (): void {
|
|
|
|
|
// GIVEN, WHEN & THEN
|
|
|
|
|
expect(fn () => new Identification(' ', '12345', 'LDC'))
|
|
|
|
|
->toThrow(\DomainException::class, 'Identification name must not be empty.');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('throws DomainException when number is empty', function (): void {
|
|
|
|
|
// GIVEN, WHEN & THEN
|
|
|
|
|
expect(fn () => new Identification('Poulet Rôti', ' ', 'LDC'))
|
|
|
|
|
->toThrow(\DomainException::class, 'Identification number must not be empty.');
|
|
|
|
|
});
|
|
|
|
|
});
|