<?php

namespace Tests\Unit\Events;

use App\Enums\LogLevelEnum;
use App\Events\ActionPerformed;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
use Tests\TestCase;

class ActionPerformedTest extends TestCase
{
    public function test_event_can_be_constructed_with_defaults(): void
    {
        $event = new ActionPerformed('Test message');

        $this->assertEquals('Test message', $event->message);
        $this->assertEquals(LogLevelEnum::INFO, $event->level);
        $this->assertEquals([], $event->context);
    }

    public function test_event_can_be_constructed_with_custom_level_and_context(): void
    {
        $context = ['article_id' => 1, 'error' => 'Something failed'];

        $event = new ActionPerformed(
            'Article validation failed',
            LogLevelEnum::ERROR,
            $context,
        );

        $this->assertEquals('Article validation failed', $event->message);
        $this->assertEquals(LogLevelEnum::ERROR, $event->level);
        $this->assertEquals($context, $event->context);
    }

    public function test_event_uses_dispatchable_trait(): void
    {
        $this->assertContains(Dispatchable::class, class_uses(ActionPerformed::class));
    }

    public function test_event_does_not_use_serializes_models_trait(): void
    {
        $this->assertNotContains(
            SerializesModels::class,
            class_uses(ActionPerformed::class),
        );
    }
}
