<?php

namespace Tests\Unit;

use App\DTO\AttendanceEventData;
use PHPUnit\Framework\TestCase;

class AttendanceEventDataTest extends TestCase
{
    public function test_it_creates_dto_from_array_and_serializes(): void
    {
        $data = [
            'device_id' => 1,
            'device_identifier' => '192.168.1.201',
            'employee_pin' => '1001',
            'attendance_time' => '2026-08-08 07:30:00',
            'verification_method' => 'fingerprint',
            'attendance_status' => 'scan',
            'source' => 'local_fingerspot',
        ];

        $dto = AttendanceEventData::fromArray($data);

        $this->assertEquals(1, $dto->deviceId);
        $this->assertEquals('192.168.1.201', $dto->deviceIdentifier);
        $this->assertEquals('1001', $dto->employeePin);
        $this->assertEquals('2026-08-08 07:30:00', $dto->attendanceTime);
        $this->assertEquals('local_fingerspot', $dto->source);

        $serialized = $dto->toArray();
        $this->assertEquals('1001', $serialized['employee_pin']);
    }
}
