diff --git a/app/Http/Controllers/SetupController.php b/app/Http/Controllers/SetupController.php index bc72403d..804e424b 100644 --- a/app/Http/Controllers/SetupController.php +++ b/app/Http/Controllers/SetupController.php @@ -245,7 +245,11 @@ class SetupController extends Controller { if (request()->is('setup') || request()->is('setup/database')) { // We're ready to install Blessing Skin, so skip the checks. - return false; + try { + DB::connection(env('DB_CONNECTION'))->getPdo(); + } catch (\Exception $e) { + return false; + } } $existingTables = []; diff --git a/tests/MiddlewareTest.php b/tests/MiddlewareTest.php index c6736069..8344ffd1 100644 --- a/tests/MiddlewareTest.php +++ b/tests/MiddlewareTest.php @@ -2,6 +2,7 @@ namespace Tests; +use DB; use App\Models\User; use App\Services\Facades\Option; use Illuminate\Support\Facades\Schema; @@ -119,6 +120,13 @@ class MiddlewareTest extends TestCase 'setup.wizard.welcome.text', ['version' => config('app.version')] )); + + DB::shouldReceive('connection')->once()->andThrow(new \Exception('fake exception')); + DB::shouldReceive('disconnect')->andReturnSelf(); + $this->get('/setup')->assertSee(trans( + 'setup.wizard.welcome.text', + ['version' => config('app.version')] + )); } public function testCheckPlayerExist()