actingAs($user)->post(route('transfer.transfers.store'), [ 'title' => $title, 'files' => [UploadedFile::fake()->create($filename, 50, 'application/pdf')], ])->assertRedirect(); return Transfer::query()->where('title', $title)->firstOrFail(); } public function test_owner_can_download_file(): void { Storage::fake('qr'); $this->fakeTransferBillingApi(); $user = User::create([ 'public_id' => (string) Str::uuid(), 'name' => 'Test User', 'email' => 'transfer+'.uniqid().'@example.com', ]); $transfer = $this->createTransfer($user, 'Docs', 'brief.pdf'); $file = $transfer->files()->first(); $this->actingAs($user) ->get(route('transfer.files.download', $file)) ->assertOk(); } public function test_owner_can_delete_file(): void { Storage::fake('qr'); $this->fakeTransferBillingApi(); $user = User::create([ 'public_id' => (string) Str::uuid(), 'name' => 'Test User', 'email' => 'transfer+'.uniqid().'@example.com', ]); $transfer = $this->createTransfer($user, 'Docs', 'brief.pdf'); $file = $transfer->files()->first(); $this->actingAs($user) ->delete(route('transfer.files.destroy', $file)) ->assertRedirect(); $this->assertDatabaseMissing('transfer_files', ['id' => $file->id]); } public function test_owner_can_move_file_to_another_transfer(): void { Storage::fake('qr'); $this->fakeTransferBillingApi(); $user = User::create([ 'public_id' => (string) Str::uuid(), 'name' => 'Test User', 'email' => 'transfer+'.uniqid().'@example.com', ]); $source = $this->createTransfer($user, 'Source folder', 'one.pdf'); $destination = $this->createTransfer($user, 'Destination folder', 'two.pdf'); $file = $source->files()->first(); $this->actingAs($user) ->post(route('transfer.files.move'), [ 'destination' => $destination->id, 'files' => [$file->id], ]) ->assertRedirect(route('transfer.files.index', ['folder' => $destination->id])); $this->assertSame($destination->id, $file->fresh()->transfer_id); } public function test_files_index_supports_folder_filter(): void { Storage::fake('qr'); $this->fakeTransferBillingApi(); $user = User::create([ 'public_id' => (string) Str::uuid(), 'name' => 'Test User', 'email' => 'transfer+'.uniqid().'@example.com', ]); $transfer = $this->createTransfer($user, 'BKC', 'cover.psd'); $this->actingAs($user) ->get(route('transfer.files.index', ['folder' => $transfer->id])) ->assertOk() ->assertSee('cover.psd') ->assertSee('BKC'); } }