feat(ticket): append variant properties to ticket name in generation process; add corresponding test case

This commit is contained in:
2026-08-10 17:10:46 -03:00
parent 69320c54d4
commit 6354e26620
2 changed files with 91 additions and 1 deletions

View File

@@ -84,6 +84,52 @@ class TicketGeneratorServiceTest extends TestCase
$this->service->generate($item->fresh(), $this->user);
}
public function test_variant_properties_are_appended_to_the_ticket_name(): void
{
$item = $this->createTicketableItem('shirt');
$color = Attribute::query()->create([
'tenant_codigo' => $this->tenant->codigo,
'codigo' => 'color',
'nombre' => 'Color',
'type' => FieldType::Select,
]);
$color->options()->create([
'value' => 'black',
'label' => 'Negro',
]);
$size = Attribute::query()->create([
'tenant_codigo' => $this->tenant->codigo,
'codigo' => 'size',
'nombre' => 'Talle',
'type' => FieldType::Select,
]);
$size->options()->create([
'value' => 'xl',
'label' => 'XL',
]);
$itemColor = $item->itemAttributes()->create([
'attribute_id' => $color->id,
'sort_order' => 1,
]);
$itemSize = $item->itemAttributes()->create([
'attribute_id' => $size->id,
'sort_order' => 2,
]);
$variant = $item->variants()->create([
'inventory_id' => Inventory::query()->create()->id,
]);
$variant->definitions()->createMany([
['item_attribute_id' => $itemColor->id, 'value' => 'black'],
['item_attribute_id' => $itemSize->id, 'value' => 'xl'],
]);
$ticket = $this->service
->generate($item, $this->user, 1, $variant->id)
->sole();
$this->assertSame('Shirt (Negro, XL)', $ticket->name);
}
public function test_it_generates_tickets_for_every_bundle_component_and_quantity(): void
{
$first = $this->createTicketableItem('first');
@@ -257,6 +303,10 @@ class TicketGeneratorServiceTest extends TestCase
['2026-08-20 00:00:00', '2026-08-21 00:00:00'],
$tickets->map(fn ($ticket): string => $ticket->validityTime->fixed_starts_at->format('Y-m-d H:i:s'))->all(),
);
$this->assertSame(
['Multi-date-pass (20/08/2026)', 'Multi-date-pass (21/08/2026)'],
$tickets->pluck('name')->all(),
);
$this->assertSame([$variant->id], $tickets->pluck('source_variant_id')->unique()->values()->all());
}