feat: implement delete functionality for accommodations, entries, foods, and merchandise; enhance related services and tests

This commit is contained in:
2026-08-10 11:33:05 -03:00
parent 4aaa66dc38
commit 2693df2cbf
14 changed files with 263 additions and 0 deletions

View File

@@ -123,6 +123,39 @@ class FoodControllerTest extends TestCase
]);
}
public function test_it_deletes_food_records_and_removes_the_empty_product(): void
{
[$tenant, $firstDate, $secondDate] = $this->configuredTenant();
Sanctum::actingAs($this->createAdminAppUser($tenant));
$created = $this->postJson('/api/v1/adminapp/tenant/foods', [
'variants' => [
$this->variantPayload($firstDate->id, 'Almuerzo', 'Comedor', 100, 10000),
$this->variantPayload($secondDate->id, 'Cena', 'Vianda', 50, 8000),
],
])->assertOk();
$firstId = $created->json('data.variants.0.id');
$secondId = $created->json('data.variants.1.id');
$this->deleteJson("/api/v1/adminapp/tenant/foods/{$secondId}")
->assertNoContent();
$this->assertDatabaseHas('catalog_items', [
'tenant_code' => $tenant->codigo,
'slug' => 'comida',
'precio' => 10000,
]);
$this->assertDatabaseCount('variantes', 1);
$this->assertDatabaseCount('inventories', 1);
$this->deleteJson("/api/v1/adminapp/tenant/foods/{$firstId}")
->assertNoContent();
$this->assertDatabaseCount('catalog_items', 0);
$this->assertDatabaseCount('variantes', 0);
$this->assertDatabaseCount('inventories', 0);
}
public function test_it_rejects_duplicate_combinations(): void
{
[$tenant, $firstDate] = $this->configuredTenant();