<?php

use App\Enums\IssueSentiment;
use App\Models\Classification;
use App\Models\Department;
use App\Models\IssueManagement;
use App\Models\Location;
use App\Models\MediaMonitoring;
use Illuminate\Foundation\Testing\RefreshDatabase;

uses(RefreshDatabase::class);

test('issue management relates monitoring and location', function () {
    $location = Location::factory()->create();
    $classification = Classification::factory()->create();
    $monitoring = MediaMonitoring::factory()->create();
    $department = Department::factory()->create();

    $issue = IssueManagement::factory()->create([
        'location_id' => $location->id,
        'classification_id' => $classification->id,
        'media_monitoring_id' => $monitoring->id,
        'issue' => IssueSentiment::POSITIVE,
    ]);

    $issue->departments()->attach($department->id);

    expect($issue->issue)->toBe(IssueSentiment::POSITIVE);
    expect($issue->location->id)->toBe($location->id);
    expect($issue->mediaMonitoring->id)->toBe($monitoring->id);
    expect($issue->departments->first()->id)->toBe($department->id);
});
