feat(variants): add filtering for inactive event dates in visibleVariants method
This commit is contained in:
@@ -346,6 +346,34 @@ class CatalogModelsTest extends TestCase
|
||||
$this->assertSame([$unavailable, $available], $item->visibleVariants()->all());
|
||||
}
|
||||
|
||||
public function test_catalog_item_never_exposes_variants_with_inactive_event_dates(): void
|
||||
{
|
||||
$activeDate = new EventDate(['date' => '2026-10-10']);
|
||||
$rescheduledDate = new EventDate([
|
||||
'date' => '2026-09-08',
|
||||
'rescheduled_to_event_date_id' => 100,
|
||||
]);
|
||||
$suspendedDate = new EventDate([
|
||||
'date' => '2026-10-08',
|
||||
'suspended_at' => now(),
|
||||
]);
|
||||
|
||||
$active = (new Variant)->setRelation('eventDates', new EloquentCollection([$activeDate]));
|
||||
$rescheduled = (new Variant)->setRelation('eventDates', new EloquentCollection([$rescheduledDate]));
|
||||
$suspended = (new Variant)->setRelation('eventDates', new EloquentCollection([$suspendedDate]));
|
||||
$active->id = 10;
|
||||
$rescheduled->id = 20;
|
||||
$suspended->id = 30;
|
||||
|
||||
$item = new CatalogItem;
|
||||
$item->inventory_policy = InventoryPolicy::Unlimited;
|
||||
$item->setRelation('variants', new EloquentCollection([$active, $rescheduled, $suspended]));
|
||||
|
||||
$this->assertSame([$active], $item->visibleVariants()->all());
|
||||
$this->assertSame([$active], $item->visibleVariants($rescheduled->id)->all());
|
||||
$this->assertSame([$active], $item->visibleVariants($suspended->id)->all());
|
||||
}
|
||||
|
||||
public function test_catalog_item_prioritizes_its_inventory_over_variants(): void
|
||||
{
|
||||
$item = new CatalogItem;
|
||||
|
||||
Reference in New Issue
Block a user