<?php

namespace Tests\Feature;

use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;

class SetupTest extends TestCase
{
    use RefreshDatabase;

    /**
     * 测试应用语言配置为简体中文
     */
    public function test_app_locale_is_chinese(): void
    {
        $this->assertEquals('zh_CN', config('app.locale'));
        $this->assertEquals('zh_CN', config('app.fallback_locale'));
    }

    /**
     * 测试数据库连接正常
     */
    public function test_database_connection(): void
    {
        // 测试数据库连接是否正常
        $this->assertDatabaseCount('users', 0); // 测试数据库初始为空
        
        // 创建一个测试用户
        \App\Models\User::factory()->create([
            'email' => 'test@example.com',
        ]);
        
        $this->assertDatabaseCount('users', 1);
        $this->assertDatabaseHas('users', [
            'email' => 'test@example.com',
        ]);
    }

    /**
     * 测试 Filament 管理面板路由可访问
     */
    public function test_filament_admin_routes_exist(): void
    {
        $response = $this->get('/admin/login');
        $response->assertStatus(200);
    }

    /**
     * 测试中文翻译文件存在
     */
    public function test_chinese_translation_files_exist(): void
    {
        $this->assertFileExists(lang_path('zh_CN/auth.php'));
        $this->assertFileExists(lang_path('zh_CN/validation.php'));
        $this->assertFileExists(lang_path('vendor/filament/zh_CN/components/button.php'));
    }
}
