feat(catalog): add scope to filter available variants and update related queries; enhance seeder and tests for stock validation
This commit is contained in:
@@ -76,6 +76,16 @@ class FiestaFutbolInfantilProductSeederTest extends TestCase
|
||||
$this->assertCount($count, $item->variants);
|
||||
}
|
||||
|
||||
$variantStocks = CatalogItem::query()
|
||||
->where('tenant_code', $tenant->codigo)
|
||||
->with('variants.inventory')
|
||||
->get()
|
||||
->flatMap(fn (CatalogItem $item) => $item->variants)
|
||||
->map(fn ($variant): int => $variant->inventory->real_stock);
|
||||
$this->assertGreaterThan($variantStocks->count() / 2, $variantStocks->filter(fn (int $stock): bool => $stock > 5)->count());
|
||||
$this->assertNotEmpty($variantStocks->filter(fn (int $stock): bool => $stock === 0));
|
||||
$this->assertNotEmpty($variantStocks->filter(fn (int $stock): bool => $stock >= 1 && $stock <= 5));
|
||||
|
||||
$this->assertSame(
|
||||
[
|
||||
'abono' => 'Entradas',
|
||||
|
||||
Reference in New Issue
Block a user