<?php

declare(strict_types=1);

namespace App\Tests\Unit\Scolarite\Application\Query\GetReplacedClassesForTeacher;

use App\Scolarite\Application\Query\GetReplacedClassesForTeacher\ReplacedClassDto;
use DateTimeImmutable;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;

final class ReplacedClassDtoTest extends TestCase
{
    private const string REPLACEMENT_ID = '550e8400-e29b-41d4-a716-446655440001';
    private const string REPLACED_TEACHER_ID = '550e8400-e29b-41d4-a716-446655440010';
    private const string CLASS_ID = '550e8400-e29b-41d4-a716-446655440020';
    private const string SUBJECT_ID = '550e8400-e29b-41d4-a716-446655440030';

    #[Test]
    public function constructorSetsAllPropertiesCorrectly(): void
    {
        $startDate = new DateTimeImmutable('2026-03-01');
        $endDate = new DateTimeImmutable('2026-03-31');

        $dto = new ReplacedClassDto(
            replacementId: self::REPLACEMENT_ID,
            replacedTeacherId: self::REPLACED_TEACHER_ID,
            classId: self::CLASS_ID,
            subjectId: self::SUBJECT_ID,
            className: '6ème A',
            subjectName: 'Mathématiques',
            startDate: $startDate,
            endDate: $endDate,
        );

        self::assertSame(self::REPLACEMENT_ID, $dto->replacementId);
        self::assertSame(self::REPLACED_TEACHER_ID, $dto->replacedTeacherId);
        self::assertSame(self::CLASS_ID, $dto->classId);
        self::assertSame(self::SUBJECT_ID, $dto->subjectId);
        self::assertSame('6ème A', $dto->className);
        self::assertSame('Mathématiques', $dto->subjectName);
        self::assertEquals($startDate, $dto->startDate);
        self::assertEquals($endDate, $dto->endDate);
    }

    #[Test]
    public function constructorPreservesExactDateValues(): void
    {
        $startDate = new DateTimeImmutable('2026-03-01 08:00:00');
        $endDate = new DateTimeImmutable('2026-03-31 23:59:59');

        $dto = new ReplacedClassDto(
            replacementId: self::REPLACEMENT_ID,
            replacedTeacherId: self::REPLACED_TEACHER_ID,
            classId: self::CLASS_ID,
            subjectId: self::SUBJECT_ID,
            className: '6ème A',
            subjectName: 'Mathématiques',
            startDate: $startDate,
            endDate: $endDate,
        );

        self::assertSame($startDate, $dto->startDate);
        self::assertSame($endDate, $dto->endDate);
    }
}
