<?php

namespace Tests\Unit\Services\System;

use App\Services\System\CleanupSchedulerService;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Cache;
use Tests\TestCase;

class CleanupSchedulerServiceTest extends TestCase
{
    public function test_should_run_when_no_cache(): void
    {
        Cache::forget('last_cleanup_run');

        $service = new CleanupSchedulerService();
        $this->assertTrue($service->shouldRun('last_cleanup_run', 2));
    }

    public function test_mark_run_sets_cache(): void
    {
        $service = new CleanupSchedulerService();
        $service->markRun('last_cleanup_run');

        $this->assertNotNull(Cache::get('last_cleanup_run'));
    }

    public function test_run_unverified_cleanup_calls_artisan(): void
    {
        Artisan::shouldReceive('call')->once()->with('users:delete-unverified');

        $service = new CleanupSchedulerService();
        $service->runUnverifiedCleanup();
    }
}
