Files
ladill-transfer/tests/Feature/TransferRecipientMailTest.php
T
isaaccladandCursor 4b616a7f04
Deploy Ladill Transfer / deploy (push) Successful in 47s
Simplify recipient emails and add live upload progress on create.
Recipients always get the download link immediately when an email is set.
Large files upload in the background with per-file and overall progress bars.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-08 13:25:43 +00:00

64 lines
1.9 KiB
PHP

<?php
namespace Tests\Feature;
use App\Notifications\TransferRecipientNotification;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Notification;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Tests\Concerns\FakesTransferBilling;
use Tests\TestCase;
class TransferRecipientMailTest extends TestCase
{
use FakesTransferBilling;
use RefreshDatabase;
public function test_create_transfer_emails_recipient_immediately(): void
{
Notification::fake();
Storage::fake('qr');
$this->fakeTransferBillingApi();
$user = $this->makeUser();
$this->actingAs($user)->post(route('transfer.transfers.store'), [
'title' => 'Project files',
'recipient_email' => 'recipient@example.com',
'files' => [UploadedFile::fake()->create('brief.pdf', 100, 'application/pdf')],
])->assertRedirect();
Notification::assertSentOnDemand(
TransferRecipientNotification::class,
fn ($notification, $channels, $notifiable) => $notifiable->routes['mail'] === 'recipient@example.com',
);
}
public function test_create_transfer_without_recipient_email_sends_no_notification(): void
{
Notification::fake();
Storage::fake('qr');
$this->fakeTransferBillingApi();
$user = $this->makeUser();
$this->actingAs($user)->post(route('transfer.transfers.store'), [
'title' => 'Project files',
'files' => [UploadedFile::fake()->create('brief.pdf', 100, 'application/pdf')],
])->assertRedirect();
Notification::assertNothingSent();
}
private function makeUser()
{
return \App\Models\User::create([
'public_id' => (string) Str::uuid(),
'name' => 'Sender',
'email' => 'sender+'.uniqid().'@example.com',
]);
}
}