<?php

namespace Tests\Unit\Services\Events;

use App\Services\Events\EventListService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;

class EventListServiceTest extends TestCase
{
    use RefreshDatabase;

    public function test_list_filters_active_events(): void
    {
        DB::table('events')->insert([
            [
                'id' => 1,
                'event_name' => 'Active',
                'event_category' => 'workshops',
                'amount' => 10,
                'expiration_date' => now()->addDays(2)->toDateString(),
                'semester' => 'Fall',
                'school_year' => '2025-2026',
                'created_at' => now(),
                'updated_at' => now(),
            ],
            [
                'id' => 2,
                'event_name' => 'Expired',
                'event_category' => 'workshops',
                'amount' => 10,
                'expiration_date' => now()->subDays(2)->toDateString(),
                'semester' => 'Fall',
                'school_year' => '2025-2026',
                'created_at' => now(),
                'updated_at' => now(),
            ],
        ]);

        $service = new EventListService();
        $result = $service->list(['active' => true, 'per_page' => 10]);

        $this->assertSame(1, $result['pagination']['total']);
    }
}
