Initial Ladill Transfer app — file sharing with QR links.
Scaffolded from the Ladill mini/events extraction pattern: multi-file transfers, retention controls, public landing pages, analytics, and Gitea deploy workflow. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\QrCode;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ImportEventsCommandTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_import_decodes_json_payload_and_remaps_programme_links(): void
|
||||
{
|
||||
Storage::fake('qr');
|
||||
|
||||
$owner = User::factory()->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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user