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', ]); } }