39 lines
1.1 KiB
PHP
39 lines
1.1 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 {
|
|
it('creates a valid warning threshold quantity', function (): void {
|
|
// GIVEN
|
|
$value = 10;
|
|
|
|
// WHEN
|
|
$threshold = new WarningThresholdQuantity($value);
|
|
|
|
// THEN
|
|
expect($threshold)->toBeInstanceOf(WarningThresholdQuantity::class)
|
|
->and($threshold->value)->toBe($value);
|
|
});
|
|
|
|
it('accepts a zero value, meaning no warning', function (): void {
|
|
// WHEN
|
|
$threshold = new WarningThresholdQuantity(0);
|
|
|
|
// THEN
|
|
expect($threshold->value)->toBe(0);
|
|
});
|
|
|
|
it('rejects a negative value', function (): void {
|
|
// WHEN
|
|
$action = fn (): WarningThresholdQuantity => new WarningThresholdQuantity(-1);
|
|
|
|
// THEN
|
|
expect($action)->toThrow(\DomainException::class, 'Warning threshold quantity cannot be negative.');
|
|
});
|
|
});
|