<?php

use App\Enums\DecisionAdmin;
use App\Models\User;
use App\Models\VerificationRequest;
use App\Models\VerificationReview;
use Illuminate\Foundation\Testing\RefreshDatabase;

uses(RefreshDatabase::class);

test('verification review can be created', function () {
    $request = VerificationRequest::factory()->create();
    $reviewer = User::factory()->create();

    $review = VerificationReview::factory()->create([
        'verification_request_id' => $request->id,
        'reviewer_id' => $reviewer->id,
        'decision' => DecisionAdmin::APPROVED,
    ]);

    expect($review->decision)->toBe(DecisionAdmin::APPROVED);
    expect($review->verificationRequest->id)->toBe($request->id);
    expect($review->reviewer->id)->toBe($reviewer->id);
});

test('verification request has many reviews', function () {
    $request = VerificationRequest::factory()->create();
    VerificationReview::factory()->count(2)->create(['verification_request_id' => $request->id]);

    expect($request->reviews)->toHaveCount(2);
});
