<?php

namespace Tests\Unit\Services;

use App\Services\DashboardStatsService;
use Illuminate\Support\Facades\Http;
use Tests\TestCase;

class DashboardStatsServiceTest extends TestCase
{
    protected function setUp(): void
    {
        parent::setUp();

        // Mock HTTP requests to prevent external calls
        Http::fake([
            '*' => Http::response('', 500),
        ]);
    }

    public function test_get_available_periods_returns_correct_options(): void
    {
        $service = new DashboardStatsService;
        $periods = $service->getAvailablePeriods();

        $this->assertIsArray($periods);
        $this->assertArrayHasKey('today', $periods);
        $this->assertArrayHasKey('week', $periods);
        $this->assertArrayHasKey('month', $periods);
        $this->assertArrayHasKey('year', $periods);
        $this->assertArrayHasKey('all', $periods);

        $this->assertEquals('Today', $periods['today']);
        $this->assertEquals('All Time', $periods['all']);
    }

    public function test_service_instantiation(): void
    {
        $service = new DashboardStatsService;
        $this->assertInstanceOf(DashboardStatsService::class, $service);
    }
}
