ldc-arcadia-api/tests/Unit/Domain/Models/ValueObjects/Inco/Composition/IdentificationTest.php

40 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace Tests\Unit\Domain\Models\ValueObjects\Inco\Composition;
use Domain\Models\ValueObjects\Inco\Composition\Identification;
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.');
});
});