<?php

namespace Tests\Unit\Dashboard\Stats;

use App\Dashboard\Stats\ArticlesPerFeed;
use App\Dashboard\Stats\BreakdownStat;
use App\Dashboard\Stats\SeriesStat;
use App\Dashboard\Stats\Stat;
use Tests\TestCase;

class StatContractTest extends TestCase
{
    public function test_the_base_contract_only_promises_identity(): void
    {
        $methods = array_map(
            fn (\ReflectionMethod $method): string => $method->getName(),
            (new \ReflectionClass(Stat::class))->getMethods(),
        );

        sort($methods);

        $this->assertSame(['key', 'label'], $methods);
    }

    public function test_a_breakdown_stat_is_a_stat(): void
    {
        $this->assertTrue(is_subclass_of(BreakdownStat::class, Stat::class));
    }

    public function test_articles_per_feed_is_a_breakdown_stat(): void
    {
        $this->assertInstanceOf(BreakdownStat::class, new ArticlesPerFeed);
    }

    public function test_a_series_stat_is_a_stat(): void
    {
        $this->assertTrue(is_subclass_of(SeriesStat::class, Stat::class));
    }
}
