<?php

namespace Ignite\Core\Tests\Unit\Console\HealthChecks;

use Ignite\Core\Console\HealthChecks\HorizonCheck;
use Illuminate\Support\Carbon;
use PHPUnit\Framework\TestCase;

class HorizonCheckTest extends TestCase
{
    /**
     * @return void
     */
    public function testGetElapsedMinutesReturnsAbsoluteIntegerMinutes(): void
    {
        $command = new TestableHorizonCheck();
        $from = Carbon::parse('2026-05-12 10:00:00');
        $to = Carbon::parse('2026-05-12 10:05:45');

        $this->assertSame(5, $command->getElapsedMinutesForTest($from, $to));
        $this->assertSame(5, $command->getElapsedMinutesForTest($to, $from));
    }
}

class TestableHorizonCheck extends HorizonCheck
{
    /**
     * @param  Carbon  $from
     * @param  Carbon  $to
     * @return int
     */
    public function getElapsedMinutesForTest(Carbon $from, Carbon $to): int
    {
        return $this->getElapsedMinutes($from, $to);
    }
}
