<?php
/*
 * Copyright 2026 Alessandro Chiapparini <sprint_planer_web@chiapparini.org>
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * See the LICENSE file in the project root for the full license text.
 */

declare(strict_types=1);

namespace App\Tests\Services\Import;

use App\Domain\TaskAssignment;
use App\Services\Import\XlsxColorClassifier;
use App\Tests\TestCase;
use PHPUnit\Framework\Attributes\DataProvider;

/**
 * Phase 20 — pure ARGB → status classifier. Table-driven against the
 * colours observed in doc/Tool_Sprint Planning.xlsx plus a handful of
 * synthetic edge cases.
 */
final class XlsxColorClassifierTest extends TestCase
{
    /** @return list<array{0:?string,1:string,2:string}> */
    public static function cases(): array
    {
        return [
            // Real cell colours present in the sample workbook.
            ['FF00B050', TaskAssignment::STATUS_ABGESCHLOSSEN, 'Excel "Green"'],
            ['FFC6EFCE', TaskAssignment::STATUS_ABGESCHLOSSEN, 'pastel green'],
            ['FFFFFF00', TaskAssignment::STATUS_GESTARTET,     'pure yellow'],
            ['FFFFEB9C', TaskAssignment::STATUS_GESTARTET,     'pale yellow'],
            ['FFFFC000', TaskAssignment::STATUS_GESTARTET,     'Excel orange'],
            ['FFC0E6F5', TaskAssignment::STATUS_ZUGEWIESEN,    'light blue'],

            // Synthetic edges.
            [null,        TaskAssignment::STATUS_ZUGEWIESEN,   'no fill'],
            ['',          TaskAssignment::STATUS_ZUGEWIESEN,   'empty hex'],
            ['00000000',  TaskAssignment::STATUS_ZUGEWIESEN,   'fully transparent'],
            ['FFFFFFFF',  TaskAssignment::STATUS_ZUGEWIESEN,   'pure white'],
            ['FF000000',  TaskAssignment::STATUS_ZUGEWIESEN,   'pure black (low S)'],
            ['FFFF0000',  TaskAssignment::STATUS_ABGEBROCHEN,  'pure red'],
            ['FFC00000',  TaskAssignment::STATUS_ABGEBROCHEN,  'dark red'],
            ['FFFFC7CE',  TaskAssignment::STATUS_ABGEBROCHEN,  'Excel "bad" red'],
            ['FF0070C0',  TaskAssignment::STATUS_ZUGEWIESEN,   'Excel blue'],
            ['FFB4A7D6',  TaskAssignment::STATUS_ZUGEWIESEN,   'lavender'],

            // 6-char (no alpha) accepted.
            ['00B050',    TaskAssignment::STATUS_ABGESCHLOSSEN, '6-char green'],
            ['#FFFF00',   TaskAssignment::STATUS_GESTARTET,    'leading hash'],

            // Garbage → fallback to default.
            ['XYZ',       TaskAssignment::STATUS_ZUGEWIESEN,   'garbage'],
            ['FF12',      TaskAssignment::STATUS_ZUGEWIESEN,   'short hex'],
        ];
    }

    #[DataProvider('cases')]
    public function testClassify(?string $argb, string $expected, string $label): void
    {
        $this->assertSame($expected, XlsxColorClassifier::classify($argb), $label);
    }
}
