- Use cases: FindAllIncoSheets & FindIncoSheet (filters, pagination, short projection) - Presentation: controllers, FormRequests with scalar validation, DTOs (camelCase) - Ports & Adapters: IncoSheetDirectory & EloquentIncoSheetDirectory - Tests: Pest 4 unit, integration, OpenAPI spectator conformance, dynamic arch tests - Docs: updated Bruno collection and OpenAPI spec
38 lines
1.1 KiB
PHP
38 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Unit\Domain\Models\ValueObjects\IncoSheets;
|
|
|
|
use Domain\Models\ValueObjects\IncoSheets\Allergen;
|
|
|
|
covers(Allergen::class);
|
|
|
|
describe('Allergen Value Object Instantiation', function (): void {
|
|
it('can be instantiated with positive code and label', function (): void {
|
|
// GIVEN
|
|
$code = 1;
|
|
$label = 'Gluten';
|
|
|
|
// WHEN
|
|
$allergen = new Allergen($code, $label);
|
|
|
|
// THEN
|
|
expect($allergen->code)->toBe(1)
|
|
->and($allergen->label)->toBe('Gluten');
|
|
});
|
|
});
|
|
|
|
describe('Allergen Value Object Domain Rules', function (): void {
|
|
it('throws DomainException for code <= 0', function (): void {
|
|
// GIVEN, WHEN & THEN
|
|
expect(fn () => new Allergen(0, 'Gluten'))
|
|
->toThrow(\DomainException::class, "Invalid code '0' shall be greater than 0");
|
|
});
|
|
|
|
it('throws DomainException for empty label', function (): void {
|
|
// GIVEN, WHEN & THEN
|
|
expect(fn () => new Allergen(1, ' '))
|
|
->toThrow(\DomainException::class, "Invalid label ' ' should not be empty");
|
|
});
|
|
});
|