<?php

namespace Tests\Unit\Services\Refunds;

use App\Services\Refunds\RefundDecisionService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;

class RefundDecisionServiceTest extends TestCase
{
    use RefreshDatabase;

    public function test_approve_updates_refund_status(): void
    {
        DB::table('refunds')->insert([
            'id' => 1,
            'parent_id' => 10,
            'school_year' => '2025-2026',
            'semester' => 'Fall',
            'refund_amount' => 50,
            'refund_paid_amount' => 0,
            'status' => 'Pending',
            'request' => 'overpayment',
            'created_at' => now(),
            'updated_at' => now(),
        ]);

        $service = new RefundDecisionService();
        $result = $service->approve(1, 2);

        $this->assertTrue($result['ok']);
        $this->assertDatabaseHas('refunds', [
            'id' => 1,
            'status' => 'Approved',
        ]);
    }
}
