make(Kernel::class)->bootstrap(); if ( ! $app->environment('testing') || config('database.default') !== 'sqlite' || config('database.connections.sqlite.database') !== ':memory:' ) { throw new RuntimeException('测试环境未使用内存 SQLite,已拒绝执行以保护共享数据库。'); } // Several migrations deliberately target the business_mirror connection. // Force that connection onto its own in-memory SQLite database before // RefreshDatabase runs, even when the developer's local .env points at // the shared production mirror. config([ 'database.connections.business_mirror' => config('database.connections.sqlite'), 'database.supplier_payable_maintenance_connection' => 'sqlite', 'jushuitan.connection' => 'business_mirror', 'upstream_mirrors.connection' => 'business_mirror', ]); $app->make(DatabaseManager::class)->purge('business_mirror'); if ( config('database.connections.business_mirror.driver') !== 'sqlite' || config('database.connections.business_mirror.database') !== ':memory:' ) { throw new RuntimeException('测试业务镜像连接未使用内存 SQLite,已拒绝执行以保护共享数据库。'); } return $app; } }