refactor(stock): implement expiration for stock reservations and add configuration

This commit is contained in:
2026-08-19 12:53:12 -03:00
parent 8d6bcdcc43
commit fdf0f3328f
4 changed files with 45 additions and 2 deletions

View File

@@ -80,6 +80,30 @@ class CartControllerTest extends TestCase
]);
}
public function test_it_sets_the_configured_expiration_when_creating_a_stock_reservation(): void
{
config()->set('catalog.stock_reservation_expiration_minutes', 45);
$now = now()->startOfSecond();
$this->travelTo($now);
$tenant = $this->createTenant('acme');
$item = $this->createDirectItem($tenant, 10, '49.90');
$this->postJson('/api/tenants/acme/cart/items', [
'catalog_item_id' => $item->id,
'cantidad' => 2,
])->assertOk();
$this->assertDatabaseHas('stock_reservations', [
'inventory_id' => $item->inventory_id,
'quantity' => 2,
'status' => 'active',
'expires_at' => $now->copy()->addMinutes(45)->toDateTimeString(),
]);
$this->travelBack();
}
public function test_it_filters_item_images_when_the_tenant_disables_them(): void
{
$tenant = $this->createTenant('acme');