Files
ladill-transfer/tests/Feature/TransferTest.php
T
isaaccladandCursor c1e3d8b3ac 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>
2026-06-08 09:25:30 +00:00

52 lines
1.6 KiB
PHP

<?php
namespace Tests\Feature;
use App\Models\Transfer;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Tests\TestCase;
class TransferTest extends TestCase
{
use RefreshDatabase;
public function test_authenticated_user_can_create_transfer_with_files(): void
{
Storage::fake('qr');
$user = User::create([
'public_id' => (string) Str::uuid(),
'name' => 'Test User',
'email' => 'transfer+'.uniqid().'@example.com',
]);
$response = $this->actingAs($user)->post(route('transfer.transfers.store'), [
'title' => 'Project assets',
'message' => 'Here are the files.',
'retention_days' => 14,
'files' => [
UploadedFile::fake()->create('brief.pdf', 100, 'application/pdf'),
UploadedFile::fake()->create('photo.jpg', 50, 'image/jpeg'),
],
]);
$response->assertRedirect();
$this->assertDatabaseCount('transfers', 1);
$this->assertDatabaseCount('transfer_files', 2);
$this->assertDatabaseHas('qr_codes', ['type' => 'transfer', 'label' => 'Project assets']);
$transfer = Transfer::first();
$this->assertNotNull($transfer->qr_code_id);
$this->assertSame(14, $transfer->retention_days);
}
public function test_dashboard_requires_auth(): void
{
$this->get(route('transfer.dashboard'))->assertRedirect();
}
}