<?php

namespace Tests\Feature\Auth;

use App\Domains\Auth\Models\User;
use App\Domains\Authorization\Enums\RoleCode;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Schema;
use Tests\TestCase;

class UserAuthorizationRelationsTest extends TestCase
{
    use RefreshDatabase;

    public function test_users_table_has_role_and_tenant_codes(): void
    {
        $this->assertTrue(Schema::hasColumns('users', [
            'rol_codigo',
            'tenant_codigo',
        ]));
    }

    public function test_a_new_user_has_the_user_role_and_no_tenant_by_default(): void
    {
        $user = User::factory()->create();

        $this->assertSame(RoleCode::User->value, $user->rol_codigo);
        $this->assertNull($user->tenant_codigo);
        $this->assertSame(RoleCode::User->value, $user->role->codigo);
        $this->assertNull($user->tenant);
    }
}
