2]); $intermediate = new Variant(['replaced_by_variant_id' => 3]); $current = new Variant(['sales_disabled_at' => now()]); $date = new EventDate; $date->id = 13; $current->setRelation('eventDates', collect([$date])); $current->setRelation('inventory', new Inventory(['real_stock' => 20])); $entry = new CatalogItem(['nombre' => 'Abono', 'precio' => 100]); $entry->setRelation('variants', collect([$original, $intermediate, $current])); $data = (new EntryResource($entry))->resolve(Request::create('/')); $this->assertSame([13], $data['event_date_ids']->all()); $this->assertSame(20, $data['stock']); $this->assertSame('Abono', $data['title']); $this->assertNotNull($current->sales_disabled_at); } public function test_it_does_not_choose_arbitrarily_between_current_variants(): void { $entry = new CatalogItem; $entry->setRelation('variants', collect([new Variant, new Variant])); $this->expectException(MultipleItemsFoundException::class); (new EntryResource($entry))->resolve(Request::create('/')); } }