create(['public_id' => 'usr_events_owner']); $payload = [ 'qr_wallets' => [], 'qr_codes' => [ [ 'platform_id' => 10, 'owner_public_id' => $owner->public_id, 'owner_email' => $owner->email, 'short_code' => 'demo-programme', 'type' => QrCode::TYPE_ITINERARY, 'label' => 'Demo Programme', 'payload' => json_encode(['content' => ['title' => 'Demo Programme'], 'style' => []]), 'is_active' => true, 'scans_total' => 0, 'created_at' => now()->toDateTimeString(), 'updated_at' => now()->toDateTimeString(), 'destination_updated_at' => now()->toDateTimeString(), ], [ 'platform_id' => 11, 'owner_public_id' => $owner->public_id, 'owner_email' => $owner->email, 'short_code' => 'demo-event', 'type' => QrCode::TYPE_EVENT, 'label' => 'Demo Event', 'payload' => json_encode([ 'content' => ['name' => 'Demo Event', 'programme_qr_id' => 10], 'style' => [], ]), 'is_active' => true, 'scans_total' => 0, 'created_at' => now()->toDateTimeString(), 'updated_at' => now()->toDateTimeString(), 'destination_updated_at' => now()->toDateTimeString(), ], ], 'qr_event_registrations' => [], 'qr_scan_events' => [], 'qr_transactions' => [], ]; $exportPath = storage_path('framework/testing/events-import.json'); if (! is_dir(dirname($exportPath))) { mkdir(dirname($exportPath), 0777, true); } file_put_contents($exportPath, json_encode($payload)); Artisan::call('events:import', [ 'file' => $exportPath, '--commit' => true, ]); $event = QrCode::where('short_code', 'demo-event')->first(); $programme = QrCode::where('short_code', 'demo-programme')->first(); $this->assertNotNull($event); $this->assertNotNull($programme); $this->assertIsArray($event->payload); $this->assertSame('Demo Event', $event->content()['name'] ?? null); $this->assertSame($programme->id, $event->content()['programme_qr_id'] ?? null); } }