<?php

namespace Tests\Unit\Services\Preferences;

use App\Services\Preferences\PreferencesCommandService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class PreferencesCommandServiceTest extends TestCase
{
    use RefreshDatabase;

    public function test_upsert_creates_record(): void
    {
        $service = app(PreferencesCommandService::class);
        $pref = $service->upsert(1, [
            'receive_email_notifications' => true,
            'receive_sms_notifications' => false,
            'theme' => 'light',
            'language' => 'en',
        ]);

        $this->assertSame(1, $pref->user_id);
        $this->assertDatabaseHas('user_preferences', [
            'user_id' => 1,
            'notification_email' => 1,
            'notification_sms' => 0,
        ]);
    }
}
