id())->toBe($id) ->and($stock->stockAmount)->toBe($stockAmount) ->and($stock->stockAdjustment)->toBe($stockAdjustment) ->and($stock->campaignCode)->toBe($campaignCode) ->and($stock->processingCode)->toBe($processingCode) ->and($stock->updatedAt)->toBeNull() ->and($stock->updatedAt())->toBeNull(); }); it('hydrates a stock with an explicit updatedAt date', function (): void { // GIVEN $updatedAt = new \DateTimeImmutable('2026-06-15 12:00:00', new \DateTimeZone('UTC')); // WHEN $stock = Stock::hydrate( StockId::generate(), new StockAmount(10), new CampaignCode('AAA01'), new ProcessingCode('PC1'), [new StockAdjustment(5, 'Inventory correction', ActorId::generate())], $updatedAt, ); // THEN expect($stock->updatedAt)->toBe($updatedAt) ->and($stock->updatedAt())->toBe($updatedAt); }); it('returns the creation date extracted from the id', function (): void { // GIVEN $expected = new \DateTimeImmutable('2024-06-15 12:34:56.789000', new \DateTimeZone('UTC')); $id = new StockId(Uuid::uuid7($expected)); $stock = Stock::hydrate( $id, new StockAmount(10), new CampaignCode('AAA01'), new ProcessingCode('PC1'), [new StockAdjustment(5, 'Inventory correction', ActorId::generate())], ); // WHEN $result = $stock->createdAt(); // THEN expect($result->format('Y-m-d H:i:s.v'))->toBe($expected->format('Y-m-d H:i:s.v')); }); });