ldc-mesbr-app/tests/Unit/Domain/Models/ValueObjects/WarningThresholdQuantityTest.php
2026-10-02 12:48:00 +02:00

48 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
namespace Tests\Unit\Domain\Models\ValueObjects;
use Domain\Models\ValueObjects\WarningThresholdQuantity;
covers(WarningThresholdQuantity::class);
describe('warning threshold quantity', function (): void {
beforeEach(function (): void {
$this->value = 10;
$this->zeroValue = 0;
$this->negativeValue = -1;
});
it('creates a valid warning threshold quantity', function (): void {
// GIVEN / WHEN
$warningThresholdQuantity = new WarningThresholdQuantity(
$this->value
);
// THEN
expect($warningThresholdQuantity)->toBeInstanceOf(WarningThresholdQuantity::class)
->and($warningThresholdQuantity->value)->toBe($this->value);
});
it('accepts a zero value, meaning no warning', function (): void {
// GIVEN / WHEN
$warningThresholdQuantity = new WarningThresholdQuantity(
$this->zeroValue
);
// THEN
expect($warningThresholdQuantity->value)->toBe($this->zeroValue);
});
it('rejects a negative value', function (): void {
// GIVEN / WHEN
$action = fn (): WarningThresholdQuantity => new WarningThresholdQuantity(
$this->negativeValue
);
// THEN
expect($action)->toThrow(\DomainException::class, 'Warning threshold quantity cannot be negative.');
});
});