Bootstrap Ladill Link from QR Plus extract template.

This commit is contained in:
isaacclad
2026-06-27 10:54:31 +00:00
commit 04e4f6ab51
243 changed files with 26587 additions and 0 deletions
+84
View File
@@ -0,0 +1,84 @@
<?php
namespace Tests\Feature;
use App\Models\QrCode;
use App\Models\QrDocument;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Storage;
use Tests\TestCase;
class ImportQrPlusCommandTest extends TestCase
{
use RefreshDatabase;
public function test_import_links_pdf_documents_and_copies_files(): void
{
Storage::fake('qr');
$user = User::factory()->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);
}
}