Compare commits
10 Commits
feature/al
...
843659583e
| Author | SHA1 | Date | |
|---|---|---|---|
| 843659583e | |||
| c2921166bd | |||
| 0f67e66b6b | |||
| 725abed06a | |||
| 743939fc63 | |||
| eb50e65fef | |||
| 1cf13501d8 | |||
| 2eeef8d392 | |||
| 87a4fa6288 | |||
| 07d2129410 |
@@ -27,6 +27,7 @@ use Illuminate\Support\Collection;
|
||||
'type',
|
||||
'slug',
|
||||
'nombre',
|
||||
'group_order',
|
||||
'descripcion',
|
||||
'precio',
|
||||
'inventory_policy',
|
||||
@@ -47,6 +48,7 @@ class CatalogItem extends Model
|
||||
'inventory_policy' => InventoryPolicy::Tracked->value,
|
||||
'inventory_subject' => InventorySubject::Product->value,
|
||||
'has_tickets' => false,
|
||||
'group_order' => 0,
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
@@ -56,6 +58,7 @@ class CatalogItem extends Model
|
||||
'brand_id' => 'integer',
|
||||
'inventory_id' => 'integer',
|
||||
'type' => CatalogItemType::class,
|
||||
'group_order' => 'integer',
|
||||
'precio' => 'decimal:2',
|
||||
'inventory_policy' => InventoryPolicy::class,
|
||||
'inventory_subject' => InventorySubject::class,
|
||||
@@ -172,17 +175,29 @@ class CatalogItem extends Model
|
||||
}
|
||||
|
||||
/** @param Builder<CatalogItem> $query */
|
||||
public function scopeWhereVariantsAvailable(Builder $query): Builder
|
||||
public function scopeWhereAvailable(Builder $query): Builder
|
||||
{
|
||||
return $query->where(function (Builder $query): void {
|
||||
$query
|
||||
->whereDoesntHave('variants')
|
||||
->orWhere('catalog_items.inventory_policy', InventoryPolicy::Unlimited->value)
|
||||
->where('catalog_items.inventory_policy', InventoryPolicy::Unlimited->value)
|
||||
->orWhereHas(
|
||||
'variants.inventory',
|
||||
fn (Builder $inventoryQuery): Builder => $inventoryQuery
|
||||
->whereColumn('inventories.real_stock', '>', 'inventories.reserved_stock')
|
||||
);
|
||||
)
|
||||
->orWhere(function (Builder $directItemQuery): void {
|
||||
$directItemQuery
|
||||
->whereDoesntHave('variants')
|
||||
->where(function (Builder $inventoryQuery): void {
|
||||
$inventoryQuery
|
||||
->whereNull('catalog_items.inventory_id')
|
||||
->orWhereHas(
|
||||
'inventory',
|
||||
fn (Builder $availableInventoryQuery): Builder => $availableInventoryQuery
|
||||
->whereColumn('inventories.real_stock', '>', 'inventories.reserved_stock')
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ class StoreCatalogItemRequest extends FormRequest
|
||||
),
|
||||
],
|
||||
'nombre' => ['required', 'string', 'max:255'],
|
||||
'group_order' => ['sometimes', 'integer', 'min:0'],
|
||||
'descripcion' => ['sometimes', 'nullable', 'string'],
|
||||
'precio' => ['required', 'numeric', 'min:0'],
|
||||
'inventory_policy' => [Rule::prohibitedIf($isBundle), 'sometimes', Rule::enum(InventoryPolicy::class)],
|
||||
|
||||
@@ -46,7 +46,7 @@ class CatalogFeaturedItemResource extends JsonResource
|
||||
$availableStock,
|
||||
$remainingUserQuota,
|
||||
),
|
||||
'variants' => $catalogItem->variants
|
||||
'variants' => $catalogItem->visibleVariants()
|
||||
->map(function (Variant $variant) use ($catalogItem, $remainingUserQuota): array {
|
||||
$variantStock = $catalogItem->inventory_policy === InventoryPolicy::Unlimited
|
||||
? null
|
||||
@@ -115,7 +115,7 @@ class CatalogFeaturedItemResource extends JsonResource
|
||||
private function firstImageUrl(CatalogItem $catalogItem): ?string
|
||||
{
|
||||
$attachment = $catalogItem->attachments->first()
|
||||
?? $catalogItem->variants
|
||||
?? $catalogItem->visibleVariants()
|
||||
->flatMap(fn (Variant $variant) => $variant->attachments)
|
||||
->first();
|
||||
|
||||
|
||||
@@ -16,8 +16,9 @@ class CatalogSearchItemResource extends JsonResource
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
$availableStock = $this->availableStock();
|
||||
$visibleVariants = $this->visibleVariants();
|
||||
$attachment = $this->attachments->first()
|
||||
?? $this->variants
|
||||
?? $visibleVariants
|
||||
->flatMap(fn (Variant $variant) => $variant->attachments)
|
||||
->first();
|
||||
|
||||
@@ -30,7 +31,7 @@ class CatalogSearchItemResource extends JsonResource
|
||||
'image' => $attachment?->getTemporaryUrl(1440),
|
||||
'maximum_addable_quantity' => $this->maximumAddable($availableStock),
|
||||
'unavailable_message' => $this->unavailableMessage($availableStock),
|
||||
'variants' => $this->variants
|
||||
'variants' => $visibleVariants
|
||||
->map(function (Variant $variant): array {
|
||||
$variantStock = $this->inventory_policy === InventoryPolicy::Unlimited
|
||||
? null
|
||||
|
||||
@@ -205,6 +205,13 @@ class CatalogService
|
||||
]);
|
||||
|
||||
$visibleVariants = $catalogItem->visibleVariants();
|
||||
if ($catalogItem->type === CatalogItemType::Standard
|
||||
&& ($catalogItem->inventory_id !== null || $catalogItem->variants->isNotEmpty())
|
||||
&& ! $catalogItem->isAvailable()) {
|
||||
throw new NotFoundHttpException('Catalog item is out of stock.');
|
||||
}
|
||||
|
||||
$catalogItem->setRelation('variants', $visibleVariants);
|
||||
$selectedVariant = $variantId === null
|
||||
? $visibleVariants->first()
|
||||
: $visibleVariants->firstWhere('id', $variantId);
|
||||
@@ -231,6 +238,7 @@ class CatalogService
|
||||
|
||||
$paginator = CatalogItem::query()
|
||||
->where('tenant_code', $tenant->codigo)
|
||||
->whereAvailable()
|
||||
->where(function (Builder $query) use ($containsPattern): void {
|
||||
$query
|
||||
->whereRaw('LOWER(nombre) LIKE ?', [$containsPattern])
|
||||
@@ -280,6 +288,7 @@ class CatalogService
|
||||
return CatalogItem::query()
|
||||
->where('tenant_code', $tenant->codigo)
|
||||
->where('category_id', $category->id)
|
||||
->whereAvailable()
|
||||
->with([
|
||||
'attachments',
|
||||
'inventory',
|
||||
|
||||
@@ -49,6 +49,7 @@ class FeaturedGroupService
|
||||
{
|
||||
$query = CatalogItem::query()
|
||||
->where('catalog_items.tenant_code', $featuredGroup->tenant_code)
|
||||
->whereAvailable()
|
||||
->where(function (Builder $query): void {
|
||||
$query
|
||||
->whereDoesntHave('category')
|
||||
@@ -81,7 +82,9 @@ class FeaturedGroupService
|
||||
FeaturedGroupSource::Category => $query
|
||||
->where('catalog_items.category_id', $featuredGroup->category_id)
|
||||
->orderBy('catalog_items.id'),
|
||||
FeaturedGroupSource::All => $query->orderBy('catalog_items.id'),
|
||||
FeaturedGroupSource::All => $query
|
||||
->orderBy('catalog_items.group_order')
|
||||
->orderBy('catalog_items.id'),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('catalog_items', function (Blueprint $table): void {
|
||||
$table->unsignedInteger('group_order')->default(0)->after('nombre');
|
||||
});
|
||||
|
||||
$footballOrder = [
|
||||
1 => [
|
||||
'slugs' => ['camiseta', 'camiseta-oficial-fnfi'],
|
||||
'names' => ['Camiseta', 'CAMISETA OFICIAL FNFI'],
|
||||
],
|
||||
2 => [
|
||||
'slugs' => ['alojamiento', 'camping'],
|
||||
'names' => ['Alojamiento', 'CAMPING'],
|
||||
],
|
||||
3 => [
|
||||
'slugs' => ['abono'],
|
||||
'names' => ['Abono', 'ABONO'],
|
||||
],
|
||||
4 => [
|
||||
'slugs' => ['comida'],
|
||||
'names' => ['Comida', 'COMIDA'],
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($footballOrder as $order => $identifiers) {
|
||||
DB::table('catalog_items')
|
||||
->where('tenant_code', 'fiesta_futbol_infantil')
|
||||
->where(function ($query) use ($identifiers): void {
|
||||
$query
|
||||
->whereIn('slug', $identifiers['slugs'])
|
||||
->orWhereIn('nombre', $identifiers['names']);
|
||||
})
|
||||
->update(['group_order' => $order]);
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('catalog_items', function (Blueprint $table): void {
|
||||
$table->dropColumn('group_order');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -78,6 +78,7 @@ class FiestaFutbolInfantilProductSeeder extends Seeder
|
||||
$this->createProduct($tenant, [
|
||||
'slug' => 'camiseta',
|
||||
'nombre' => 'Camiseta',
|
||||
'group_order' => 1,
|
||||
'category_id' => $categories['merchandising']->id,
|
||||
'precio' => 18000,
|
||||
'attribute_codes' => ['color', 'talle'],
|
||||
@@ -92,6 +93,7 @@ class FiestaFutbolInfantilProductSeeder extends Seeder
|
||||
$this->createProduct($tenant, [
|
||||
'slug' => 'alojamiento',
|
||||
'nombre' => 'Alojamiento',
|
||||
'group_order' => 2,
|
||||
'category_id' => $categories['alojamientos']->id,
|
||||
'precio' => 35000,
|
||||
'attribute_codes' => ['tipo_alojamiento'],
|
||||
@@ -104,6 +106,7 @@ class FiestaFutbolInfantilProductSeeder extends Seeder
|
||||
$this->createProduct($tenant, [
|
||||
'slug' => 'comida',
|
||||
'nombre' => 'Comida',
|
||||
'group_order' => 4,
|
||||
'category_id' => $categories['comidas']->id,
|
||||
'precio' => 4000,
|
||||
'attribute_codes' => ['event_date', 'horario', 'servicio'],
|
||||
@@ -126,6 +129,7 @@ class FiestaFutbolInfantilProductSeeder extends Seeder
|
||||
$this->createProduct($tenant, [
|
||||
'slug' => 'abono',
|
||||
'nombre' => 'Abono',
|
||||
'group_order' => 3,
|
||||
'category_id' => $categories['entradas']->id,
|
||||
'precio' => 40000,
|
||||
'has_tickets' => true,
|
||||
|
||||
@@ -73,19 +73,18 @@ class CatalogControllerTest extends TestCase
|
||||
->assertJsonPath('0.items.0.descripcion', 'Variants description')
|
||||
->assertJsonPath('0.items.0.precio', '100.00')
|
||||
->assertJsonPath('0.items.0.maximum_addable_quantity', 7)
|
||||
->assertJsonCount(3, '0.items.0.variants')
|
||||
->assertJsonCount(2, '0.items.0.variants')
|
||||
->assertJsonPath('0.items.0.variants.0.maximum_addable_quantity', 4)
|
||||
->assertJsonPath('0.items.0.variants.1.maximum_addable_quantity', 3)
|
||||
->assertJsonPath('0.items.0.variants.2.id', $unavailableVariant->id)
|
||||
->assertJsonPath('0.items.0.variants.2.maximum_addable_quantity', 0)
|
||||
->assertJsonPath(
|
||||
'0.items.0.variants.2.unavailable_message',
|
||||
'Este producto no tiene stock disponible.',
|
||||
)
|
||||
->assertJsonPath('1.title', 'Row')
|
||||
->assertJsonPath('1.items.data.0.maximum_addable_quantity', 8)
|
||||
->assertJsonMissingPath('1.items.data.0.stock_tecnico')
|
||||
->assertJsonCount(0, '1.items.data.0.variants');
|
||||
|
||||
$this->assertNotContains(
|
||||
$unavailableVariant->id,
|
||||
collect($response->json('0.items.0.variants'))->pluck('id')->all(),
|
||||
);
|
||||
}
|
||||
|
||||
public function test_maximum_addable_quantity_shares_the_authenticated_user_quota_between_variants(): void
|
||||
@@ -133,7 +132,7 @@ class CatalogControllerTest extends TestCase
|
||||
->assertJsonMissingPath('0.items.0.variants.1.stock_tecnico');
|
||||
}
|
||||
|
||||
public function test_it_includes_out_of_stock_items_with_an_unavailable_message(): void
|
||||
public function test_it_excludes_out_of_stock_items(): void
|
||||
{
|
||||
$tenant = $this->createTenant('catalog-available-variants');
|
||||
$group = $this->createGroup(
|
||||
@@ -161,15 +160,10 @@ class CatalogControllerTest extends TestCase
|
||||
|
||||
$this->getJson("/api/tenants/{$tenant->codigo}/catalog")
|
||||
->assertOk()
|
||||
->assertJsonCount(2, '0.items')
|
||||
->assertJsonPath('0.items.0.nombre', 'Unavailable')
|
||||
->assertJsonPath('0.items.0.maximum_addable_quantity', 0)
|
||||
->assertJsonPath(
|
||||
'0.items.0.unavailable_message',
|
||||
'Este producto no tiene stock disponible.',
|
||||
)
|
||||
->assertJsonPath('0.items.1.nombre', 'Available')
|
||||
->assertJsonPath('0.items.1.unavailable_message', null);
|
||||
->assertJsonCount(1, '0.items')
|
||||
->assertJsonPath('0.items.0.nombre', 'Available')
|
||||
->assertJsonPath('0.items.0.unavailable_message', null)
|
||||
->assertJsonMissing(['nombre' => 'Unavailable']);
|
||||
}
|
||||
|
||||
public function test_column_with_image_uses_item_image_then_variant_image_then_null(): void
|
||||
@@ -354,8 +348,10 @@ class CatalogControllerTest extends TestCase
|
||||
]);
|
||||
|
||||
$food = $this->createItem($tenant, 'Hamburger');
|
||||
$food->update(['group_order' => 2]);
|
||||
$food->category()->associate($category)->save();
|
||||
$this->createItem($tenant, 'Parking');
|
||||
$parking = $this->createItem($tenant, 'Parking');
|
||||
$parking->update(['group_order' => 1]);
|
||||
|
||||
$this->getJson("/api/tenants/{$tenant->codigo}/catalog")
|
||||
->assertOk()
|
||||
@@ -364,6 +360,9 @@ class CatalogControllerTest extends TestCase
|
||||
->assertJsonPath('0.items.0.nombre', 'Hamburger')
|
||||
->assertJsonPath('1.title', 'All products')
|
||||
->assertJsonCount(2, '1.items.data')
|
||||
->assertJsonPath('1.items.data.0.nombre', 'Parking')
|
||||
->assertJsonPath('1.items.data.1.nombre', 'Hamburger')
|
||||
->assertJsonMissingPath('1.items.data.0.group_order')
|
||||
->assertJsonPath('1.items.meta.total', 2);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ class CatalogItemControllerTest extends TestCase
|
||||
$response = $this->postJson("/api/tenants/{$tenant->codigo}/catalog-items", [
|
||||
'slug' => 'shirt',
|
||||
'nombre' => 'Shirt',
|
||||
'group_order' => 7,
|
||||
'precio' => 100,
|
||||
'max_units_per_user' => 4,
|
||||
'attribute_codes' => [$attribute->codigo],
|
||||
@@ -47,6 +48,7 @@ class CatalogItemControllerTest extends TestCase
|
||||
$response
|
||||
->assertCreated()
|
||||
->assertJsonPath('data.nombre', 'Shirt')
|
||||
->assertJsonMissingPath('data.group_order')
|
||||
->assertJsonPath('data.max_units_per_user', 4)
|
||||
->assertJsonCount(2, 'data.images')
|
||||
->assertJsonCount(1, 'data.variants')
|
||||
@@ -57,6 +59,7 @@ class CatalogItemControllerTest extends TestCase
|
||||
|
||||
$this->assertSame([0, 1], $item->attachments()->get()->pluck('pivot.orden')->all());
|
||||
$this->assertSame(4, $item->max_units_per_user);
|
||||
$this->assertSame(7, $item->group_order);
|
||||
$this->assertSame([0], $variant->attachments()->get()->pluck('pivot.orden')->all());
|
||||
$this->assertDatabaseHas('catalog_items_attachments', [
|
||||
'catalog_item_id' => $item->id,
|
||||
|
||||
@@ -48,7 +48,7 @@ class CatalogItemDetailControllerTest extends TestCase
|
||||
$this->assertStringContainsString($itemImage->path, $response->json('data.images.0'));
|
||||
}
|
||||
|
||||
public function test_it_lists_unavailable_variants_and_selects_the_first_available_one(): void
|
||||
public function test_it_omits_unavailable_variants_and_selects_the_first_available_one(): void
|
||||
{
|
||||
Storage::fake('s3');
|
||||
$tenant = $this->createTenant('detail-default');
|
||||
@@ -69,14 +69,8 @@ class CatalogItemDetailControllerTest extends TestCase
|
||||
|
||||
$response
|
||||
->assertOk()
|
||||
->assertJsonCount(2, 'data.variants')
|
||||
->assertJsonPath('data.variants.0.id', $firstVariant->id)
|
||||
->assertJsonPath('data.variants.0.maximum_addable_quantity', 0)
|
||||
->assertJsonPath(
|
||||
'data.variants.0.unavailable_message',
|
||||
'Este producto no tiene stock disponible.',
|
||||
)
|
||||
->assertJsonPath('data.variants.1.id', $secondVariant->id)
|
||||
->assertJsonCount(1, 'data.variants')
|
||||
->assertJsonPath('data.variants.0.id', $secondVariant->id)
|
||||
->assertJsonPath('data.selected_variant.id', $secondVariant->id)
|
||||
->assertJsonPath('data.selected_variant.maximum_addable_quantity', 6)
|
||||
->assertJsonMissingPath('data.selected_variant.stock_tecnico')
|
||||
@@ -84,6 +78,10 @@ class CatalogItemDetailControllerTest extends TestCase
|
||||
$response
|
||||
->assertJsonMissingPath('data.stock_tecnico')
|
||||
->assertJsonMissingPath('data.images');
|
||||
$this->assertNotContains(
|
||||
$firstVariant->id,
|
||||
collect($response->json('data.variants'))->pluck('id')->all(),
|
||||
);
|
||||
$this->assertStringContainsString($secondImage->path, $response->json('data.selected_variant.images.0'));
|
||||
$this->assertStringNotContainsString($firstImage->path, $response->json('data.selected_variant.images.0'));
|
||||
$this->assertStringNotContainsString($itemImage->path, $response->json('data.selected_variant.images.0'));
|
||||
@@ -93,6 +91,19 @@ class CatalogItemDetailControllerTest extends TestCase
|
||||
)->assertNotFound();
|
||||
}
|
||||
|
||||
public function test_it_does_not_return_an_out_of_stock_item(): void
|
||||
{
|
||||
$tenant = $this->createTenant('detail-out-of-stock');
|
||||
$inventory = Inventory::query()->create([
|
||||
'real_stock' => 5,
|
||||
'reserved_stock' => 5,
|
||||
]);
|
||||
$item = $this->createItem($tenant, 'Sold out item', $inventory);
|
||||
|
||||
$this->getJson("/api/tenants/{$tenant->codigo}/catalog-items/{$item->id}")
|
||||
->assertNotFound();
|
||||
}
|
||||
|
||||
public function test_it_selects_the_requested_variant_and_lists_variant_values_and_stock(): void
|
||||
{
|
||||
Storage::fake('s3');
|
||||
|
||||
@@ -62,6 +62,24 @@ class CatalogSearchTest extends TestCase
|
||||
$this->createCatalogItem($tenant, "Running {$number}");
|
||||
}
|
||||
$exactMatch = $this->createCatalogItem($tenant, 'Running');
|
||||
$outOfStock = CatalogItem::query()->create([
|
||||
'tenant_code' => $tenant->codigo,
|
||||
'slug' => 'running-sold-out',
|
||||
'nombre' => 'Running sold out',
|
||||
'descripcion' => 'Running sold out description',
|
||||
'precio' => 100,
|
||||
]);
|
||||
$outOfStock->variants()->create([
|
||||
'inventory_id' => Inventory::query()->create(['real_stock' => 0])->id,
|
||||
]);
|
||||
CatalogItem::query()->create([
|
||||
'tenant_code' => $tenant->codigo,
|
||||
'inventory_id' => Inventory::query()->create(['real_stock' => 2, 'reserved_stock' => 2])->id,
|
||||
'slug' => 'running-direct-sold-out',
|
||||
'nombre' => 'Running direct sold out',
|
||||
'descripcion' => 'Running direct sold out description',
|
||||
'precio' => 100,
|
||||
]);
|
||||
$this->createCatalogItem($tenant, 'Unrelated');
|
||||
$this->createCatalogItem($otherTenant, 'Running foreign');
|
||||
|
||||
@@ -76,6 +94,8 @@ class CatalogSearchTest extends TestCase
|
||||
->assertJsonPath('meta.total', 6)
|
||||
->assertJsonCount(4, 'data')
|
||||
->assertJsonPath('data.0.id', $exactMatch->id)
|
||||
->assertJsonMissing(['nombre' => 'Running sold out'])
|
||||
->assertJsonMissing(['nombre' => 'Running direct sold out'])
|
||||
->assertJsonMissing(['nombre' => 'Running foreign'])
|
||||
->assertJsonMissing(['nombre' => 'Unrelated']);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,17 @@ class CategoryDetailTest extends TestCase
|
||||
$this->createCatalogItem($tenant, $category, 'Remera C');
|
||||
$firstItem = $this->createCatalogItem($tenant, $category, 'Remera A');
|
||||
$secondItem = $this->createCatalogItem($tenant, $category, 'Remera B');
|
||||
$outOfStock = CatalogItem::query()->create([
|
||||
'tenant_code' => $tenant->codigo,
|
||||
'category_id' => $category->id,
|
||||
'slug' => 'remera-agotada',
|
||||
'nombre' => 'Remera agotada',
|
||||
'descripcion' => 'Sin stock',
|
||||
'precio' => 100,
|
||||
]);
|
||||
$outOfStock->variants()->create([
|
||||
'inventory_id' => Inventory::query()->create(['real_stock' => 0])->id,
|
||||
]);
|
||||
$this->createCatalogItem($tenant, $otherCategory, 'Pantalón');
|
||||
|
||||
$this->getJson("/api/tenants/{$tenant->codigo}/categories/{$category->id}")
|
||||
@@ -44,6 +55,7 @@ class CategoryDetailTest extends TestCase
|
||||
->assertJsonCount(2, 'data')
|
||||
->assertJsonPath('data.0.id', $firstItem->id)
|
||||
->assertJsonPath('data.1.id', $secondItem->id)
|
||||
->assertJsonMissing(['nombre' => 'Remera agotada'])
|
||||
->assertJsonMissing(['nombre' => 'Pantalón']);
|
||||
}
|
||||
|
||||
|
||||
@@ -70,6 +70,14 @@ class FiestaFutbolInfantilProductSeederTest extends TestCase
|
||||
['abono', 'alojamiento', 'camiseta', 'comida'],
|
||||
CatalogItem::query()->where('tenant_code', $tenant->codigo)->orderBy('slug')->pluck('slug')->all(),
|
||||
);
|
||||
$this->assertSame(
|
||||
['camiseta', 'alojamiento', 'abono', 'comida'],
|
||||
CatalogItem::query()
|
||||
->where('tenant_code', $tenant->codigo)
|
||||
->orderBy('group_order')
|
||||
->pluck('slug')
|
||||
->all(),
|
||||
);
|
||||
$this->assertTrue(
|
||||
CatalogItem::query()
|
||||
->where('tenant_code', $tenant->codigo)
|
||||
|
||||
@@ -83,11 +83,13 @@ class CatalogModelsTest extends TestCase
|
||||
public function test_catalog_item_is_the_catalog_root(): void
|
||||
{
|
||||
$item = new CatalogItem;
|
||||
$this->assertSame(0, $item->group_order);
|
||||
$item->setRawAttributes([
|
||||
'category_id' => '10',
|
||||
'brand_id' => '20',
|
||||
'inventory_id' => '30',
|
||||
'type' => CatalogItemType::Standard->value,
|
||||
'group_order' => '4',
|
||||
'precio' => '12.50',
|
||||
'inventory_policy' => InventoryPolicy::Tracked->value,
|
||||
'inventory_subject' => InventorySubject::Seat->value,
|
||||
@@ -100,6 +102,7 @@ class CatalogModelsTest extends TestCase
|
||||
$this->assertSame(20, $item->brand_id);
|
||||
$this->assertSame(30, $item->inventory_id);
|
||||
$this->assertSame(CatalogItemType::Standard, $item->type);
|
||||
$this->assertSame(4, $item->group_order);
|
||||
$this->assertSame('12.50', $item->precio);
|
||||
$this->assertSame(InventoryPolicy::Tracked, $item->inventory_policy);
|
||||
$this->assertSame(InventorySubject::Seat, $item->inventory_subject);
|
||||
|
||||
Reference in New Issue
Block a user