fedi-feed-router/backend/tests/Unit/Services/DashboardStatsServiceTest.php

42 lines
1.2 KiB
PHP
Raw Normal View History

2025-08-02 03:48:06 +02:00
<?php
namespace Tests\Unit\Services;
use App\Services\DashboardStatsService;
use Tests\TestCase;
2025-08-10 04:16:53 +02:00
use Illuminate\Support\Facades\Http;
2025-08-02 03:48:06 +02:00
class DashboardStatsServiceTest extends TestCase
{
protected function setUp(): void
{
parent::setUp();
2025-08-10 04:16:53 +02:00
// Mock HTTP requests to prevent external calls
Http::fake([
'*' => Http::response('', 500)
2025-08-02 03:48:06 +02:00
]);
}
public function test_get_available_periods_returns_correct_options(): void
{
2025-08-10 04:16:53 +02:00
$service = new DashboardStatsService();
$periods = $service->getAvailablePeriods();
2025-08-02 03:48:06 +02:00
$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']);
}
2025-08-10 04:16:53 +02:00
public function test_service_instantiation(): void
2025-08-02 03:48:06 +02:00
{
2025-08-10 04:16:53 +02:00
$service = new DashboardStatsService();
$this->assertInstanceOf(DashboardStatsService::class, $service);
2025-08-02 03:48:06 +02:00
}
}