<?php

namespace Tests\Unit\Services\Auth;

use App\Services\Auth\RegistrationCaptchaService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class RegistrationCaptchaServiceTest extends TestCase
{
    use RefreshDatabase;

    public function test_generate_sets_cache_value(): void
    {
        $service = new RegistrationCaptchaService();
        $value = $service->generate(6);

        $this->assertNotEmpty($value);
        $this->assertTrue($service->verify($value));
    }

    public function test_verify_and_clear(): void
    {
        $service = new RegistrationCaptchaService();
        $value = $service->generate(6);

        $this->assertTrue($service->verify($value));
        $this->assertFalse($service->verify('WRONG'));

        $service->clear();
        $this->assertFalse($service->verify($value));
    }
}
