28 lines
791 B
PHP
28 lines
791 B
PHP
<?php
|
|
|
|
namespace Tests\Unit\Services\Auth;
|
|
|
|
use App\Services\Auth\PasswordResetCleanupService;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Tests\TestCase;
|
|
|
|
class PasswordResetCleanupServiceTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_cleanup_removes_old_requests(): void
|
|
{
|
|
DB::table('password_reset_requests')->insert([
|
|
['ip_address' => '127.0.0.1', 'requested_at' => now()->subDays(40)],
|
|
['ip_address' => '127.0.0.1', 'requested_at' => now()->subDays(5)],
|
|
]);
|
|
|
|
$service = new PasswordResetCleanupService;
|
|
$deleted = $service->cleanup(30);
|
|
|
|
$this->assertSame(1, $deleted);
|
|
$this->assertDatabaseCount('password_reset_requests', 1);
|
|
}
|
|
}
|