<?php

namespace Tests\Unit;

use App\Services\IcNumberService;
use Tests\TestCase;

class IcNumberServiceTest extends TestCase
{
    private IcNumberService $service;

    protected function setUp(): void
    {
        parent::setUp();
        $this->service = app(IcNumberService::class);
    }

    public function test_normalize_removes_non_digits(): void
    {
        $this->assertEquals('900101101234', $this->service->normalize('900101-10-1234'));
    }

    public function test_validate_12_digits(): void
    {
        $this->assertTrue($this->service->validate('900101101234'));
        $this->assertFalse($this->service->validate('12345'));
    }

    public function test_hash_is_consistent(): void
    {
        $hash1 = $this->service->hash('900101101234');
        $hash2 = $this->service->hash('900101-10-1234');

        $this->assertEquals($hash1, $hash2);
    }

    public function test_encrypt_decrypt(): void
    {
        $encrypted = $this->service->encrypt('900101101234');
        $decrypted = $this->service->decrypt($encrypted);

        $this->assertEquals('900101101234', $decrypted);
    }

    public function test_format_12_digits(): void
    {
        $this->assertEquals('900101-10-1234', $this->service->format('900101101234'));
    }
}
