create(['public_id' => 'usr_test_pdf']); $sourceRoot = storage_path('framework/testing/platform-qr'); $relativePath = $user->id.'/documents/test-menu.pdf'; $sourceFile = $sourceRoot.'/'.$relativePath; if (! is_dir(dirname($sourceFile))) { mkdir(dirname($sourceFile), 0777, true); } file_put_contents($sourceFile, '%PDF-1.4 test'); $payload = [ 'qr_wallets' => [], 'qr_documents' => [[ 'platform_id' => 42, 'owner_public_id' => $user->public_id, 'owner_email' => $user->email, 'title' => 'Menu PDF', 'disk' => 'qr', 'path' => $relativePath, 'mime_type' => 'application/pdf', 'size_bytes' => 12, 'page_count' => null, 'created_at' => now()->toDateTimeString(), 'updated_at' => now()->toDateTimeString(), ]], 'qr_codes' => [[ 'platform_id' => 99, 'platform_qr_document_id' => 42, 'owner_public_id' => $user->public_id, 'owner_email' => $user->email, 'short_code' => 'menu-pdf', 'type' => QrCode::TYPE_DOCUMENT, 'label' => 'Menu PDF', 'destination_url' => null, 'payload' => json_encode(['content' => ['allow_download' => true], 'style' => []]), 'is_active' => true, 'scans_total' => 0, 'created_at' => now()->toDateTimeString(), 'updated_at' => now()->toDateTimeString(), 'destination_updated_at' => now()->toDateTimeString(), ]], 'qr_scan_events' => [], 'qr_transactions' => [], ]; $exportPath = storage_path('framework/testing/qr-plus-import.json'); file_put_contents($exportPath, json_encode($payload)); Artisan::call('qr-plus:import', [ 'file' => $exportPath, '--commit' => true, '--storage-source' => $sourceRoot, ]); $code = QrCode::where('short_code', 'menu-pdf')->first(); $this->assertNotNull($code); $this->assertNotNull($code->qr_document_id); $document = QrDocument::find($code->qr_document_id); $this->assertNotNull($document); $this->assertSame($relativePath, $document->path); Storage::disk('qr')->assertExists($relativePath); } }