<?php

namespace Tests\Unit\Services\ClassProgress;

use App\Models\ClassProgressReport;
use App\Services\ClassProgress\ClassProgressAttachmentService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
use Tests\TestCase;

class ClassProgressAttachmentServiceTest extends TestCase
{
    use RefreshDatabase;

    public function test_store_attachments_persists_records(): void
    {
        Storage::fake('public');

        $report = ClassProgressReport::factory()->create();
        $service = new ClassProgressAttachmentService();

        $files = [UploadedFile::fake()->create('sample.pdf', 12)];
        $stored = $service->storeAttachments($report->id, $files);

        $this->assertCount(1, $stored);
        $this->assertDatabaseHas('class_progress_attachments', [
            'report_id' => $report->id,
        ]);
    }
}
