quantity = 10; $this->zeroQuantity = 0; $this->negativeQuantity = -5; $this->reason = 'Inventory correction'; }); it('creates a valid stock adjustment', function (): void { // GIVEN $actorId = ActorId::generate(); // WHEN $adjustment = new StockAdjustment( $this->quantity, $this->reason, $actorId ); // THEN expect($adjustment)->toBeInstanceOf(StockAdjustment::class) ->and($adjustment->quantity)->toBe($this->quantity) ->and($adjustment->reason)->toBe($this->reason) ->and($adjustment->actorId)->toBe($actorId) ->and($adjustment->createdAt)->toBeNull(); }); it('creates a stock adjustment with an explicit createdAt date', function (): void { // GIVEN $actorId = ActorId::generate(); $createdAt = new \DateTimeImmutable('2026-06-15 12:00:00', new \DateTimeZone('UTC')); // WHEN $adjustment = new StockAdjustment( $this->quantity, $this->reason, $actorId, $createdAt ); // THEN expect($adjustment->createdAt)->toBe($createdAt); }); it('rejects a quantity of zero', function (): void { // GIVEN $actorId = ActorId::generate(); // WHEN $action = fn (): StockAdjustment => new StockAdjustment( $this->zeroQuantity, $this->reason, $actorId ); // THEN expect($action)->toThrow(\DomainException::class, 'Stock Amount should be more than 0.'); }); it('rejects a negative quantity', function (): void { // GIVEN $actorId = ActorId::generate(); // WHEN $action = fn (): StockAdjustment => new StockAdjustment( $this->negativeQuantity, $this->reason, $actorId ); // THEN expect($action)->toThrow(\DomainException::class, 'Stock Amount should be more than 0.'); }); });