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;
|
2026-08-14 11:33:05 +02:00
|
|
|
|
2026-08-14 15:38:10 +02:00
|
|
|
use Domain\Models\ValueObjects\Inco\IncoWeight;
|
2026-08-14 11:33:05 +02:00
|
|
|
|
|
|
|
|
covers(IncoWeight::class);
|
|
|
|
|
|
2026-08-14 15:38:10 +02:00
|
|
|
describe('IncoWeight Value Object Instantiation', function (): void {
|
|
|
|
|
it('can be instantiated with valid weight numbers', function (): void {
|
2026-08-14 11:33:05 +02:00
|
|
|
// GIVEN
|
2026-08-14 15:38:10 +02:00
|
|
|
$net = 1000;
|
|
|
|
|
$gross = 1200;
|
|
|
|
|
$avg = 1100;
|
2026-08-14 11:33:05 +02:00
|
|
|
|
|
|
|
|
// WHEN
|
2026-08-14 15:38:10 +02:00
|
|
|
$weight = new IncoWeight($net, $gross, $avg);
|
2026-08-14 11:33:05 +02:00
|
|
|
|
|
|
|
|
// THEN
|
2026-08-14 15:38:10 +02:00
|
|
|
expect($weight->netWeight)->toBe(1000)
|
|
|
|
|
->and($weight->grossWeight)->toBe(1200)
|
|
|
|
|
->and($weight->theoreticalAverage)->toBe(1100);
|
2026-08-14 11:33:05 +02:00
|
|
|
});
|
2026-08-14 15:38:10 +02:00
|
|
|
});
|
2026-08-14 11:33:05 +02:00
|
|
|
|
2026-08-14 15:38:10 +02:00
|
|
|
describe('IncoWeight Value Object Domain Rules', function (): void {
|
|
|
|
|
it('throws DomainException for negative weight', function (): void {
|
2026-08-14 11:33:05 +02:00
|
|
|
// GIVEN, WHEN & THEN
|
2026-08-14 15:38:10 +02:00
|
|
|
expect(fn () => new IncoWeight(-1, 100, 100))
|
2026-08-14 11:33:05 +02:00
|
|
|
->toThrow(\DomainException::class, 'Weight values must be non-negative.');
|
|
|
|
|
});
|
|
|
|
|
});
|