<?php

declare(strict_types=1);

namespace Tests\Unit;

use App\Support\BlogHomepageDisplay;
use PHPUnit\Framework\TestCase;

final class BlogHomepageDisplayTest extends TestCase
{
    public function test_synthetic_floor_is_at_least_minimum_and_varies_by_key(): void
    {
        $a = BlogHomepageDisplay::syntheticFloor('c:1');
        $b = BlogHomepageDisplay::syntheticFloor('c:2');
        $this->assertGreaterThanOrEqual(4000, $a);
        $this->assertGreaterThanOrEqual(4000, $b);
        $this->assertLessThanOrEqual(15_000, $a);
        $this->assertLessThanOrEqual(15_000, $b);
        $this->assertNotSame($a, $b);
    }

    public function test_category_and_tag_same_numeric_id_get_different_floors(): void
    {
        $this->assertNotSame(
            BlogHomepageDisplay::syntheticFloor('c:5'),
            BlogHomepageDisplay::syntheticFloor('t:5')
        );
    }

    public function test_article_count_uses_actual_when_above_synthetic_floor(): void
    {
        $this->assertSame(
            20_000,
            BlogHomepageDisplay::articleCount(20_000, 'c:1')
        );
    }

    public function test_article_count_uses_synthetic_when_actual_is_lower(): void
    {
        $v = BlogHomepageDisplay::articleCount(2, 'c:99');
        $this->assertGreaterThanOrEqual(4000, $v);
        $this->assertGreaterThan(2, $v);
    }
}
