Merge branch 'refactor/inventory_stock' of https://gitea.quo.ar/tbianchini/shopit-back into refactor/inventory_stock

This commit is contained in:
2026-09-29 08:23:09 -03:00
parent c5aeb19735
commit 96378a6c2e
596 changed files with 239 additions and 7622 deletions

View File

@@ -72,29 +72,6 @@ class CategoryDetailTest extends TestCase
->assertJsonCount(0, 'data');
}
public function test_it_includes_products_from_all_descendant_categories(): void
{
$tenant = $this->createTenant('category-descendants');
$parent = $this->createCategory($tenant, 'Indumentaria');
$child = $this->createCategory($tenant, 'Remeras', $parent);
$grandchild = $this->createCategory($tenant, 'Manga corta', $child);
$sibling = $this->createCategory($tenant, 'Pantalones');
$parentItem = $this->createCatalogItem($tenant, $parent, 'Producto padre');
$childItem = $this->createCatalogItem($tenant, $child, 'Producto hijo');
$grandchildItem = $this->createCatalogItem($tenant, $grandchild, 'Producto nieto');
$this->createCatalogItem($tenant, $sibling, 'Producto ajeno');
$this->getJson("/api/tenants/{$tenant->codigo}/categories/{$parent->id}")
->assertOk()
->assertJsonPath('meta.total', 3)
->assertJsonCount(3, 'data')
->assertJsonPath('data.0.id', $childItem->id)
->assertJsonPath('data.1.id', $grandchildItem->id)
->assertJsonPath('data.2.id', $parentItem->id)
->assertJsonMissing(['nombre' => 'Producto ajeno']);
}
public function test_it_rejects_categories_from_another_tenant(): void
{
$tenant = $this->createTenant('category-owner');
@@ -130,14 +107,10 @@ class CategoryDetailTest extends TestCase
]);
}
private function createCategory(
Tenant $tenant,
string $name,
?Category $parent = null,
): Category {
private function createCategory(Tenant $tenant, string $name): Category
{
return Category::query()->create([
'tenant_code' => $tenant->codigo,
'categoria_id' => $parent?->id,
'nombre' => $name,
]);
}