Deploy Ladill Transfer / deploy (push) Successful in 1m0s
Send grace-entered and countdown emails to owners alongside recipient grace milestones so unpaid transfers get clear wallet top-up reminders before deletion. Co-authored-by: Cursor <cursoragent@cursor.com>
46 lines
1.4 KiB
PHP
46 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Models\Transfer;
|
|
use App\Models\User;
|
|
use App\Notifications\TransferOwnerGraceNotification;
|
|
use App\Services\Transfer\TransferOwnerMailService;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\Notification;
|
|
use Illuminate\Support\Str;
|
|
use Tests\TestCase;
|
|
|
|
class TransferOwnerGraceMailTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_owner_grace_day_milestone_is_sent_once(): void
|
|
{
|
|
Notification::fake();
|
|
|
|
$user = User::create([
|
|
'public_id' => (string) Str::uuid(),
|
|
'name' => 'Owner',
|
|
'email' => 'owner+'.uniqid().'@example.com',
|
|
]);
|
|
|
|
$transfer = Transfer::create([
|
|
'user_id' => $user->id,
|
|
'title' => 'Grace reminder',
|
|
'retention_days' => 30,
|
|
'paid_until' => now()->subDay(),
|
|
'grace_ends_at' => now()->addDays(3)->startOfDay(),
|
|
'status' => Transfer::STATUS_GRACE,
|
|
'storage_bytes' => 1024,
|
|
'owner_milestones_sent' => ['grace_entered'],
|
|
]);
|
|
|
|
$service = app(TransferOwnerMailService::class);
|
|
$this->assertSame(1, $service->processGraceReminders());
|
|
$this->assertSame(0, $service->processGraceReminders());
|
|
|
|
Notification::assertSentTo($user, TransferOwnerGraceNotification::class, 1);
|
|
}
|
|
}
|