<?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_session_value(): void
    {
        $service = new RegistrationCaptchaService();
        $value = $service->generate(6);

        $this->assertNotEmpty($value);
        $this->assertSame($value, session()->get('captcha_answer'));
    }

    public function test_verify_and_clear(): void
    {
        $service = new RegistrationCaptchaService();
        session()->put('captcha_answer', 'ABC123');

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

        $service->clear();
        $this->assertNull(session()->get('captcha_answer'));
    }
}
