assertFalse($role->rolsuper); $this->assertFalse($role->rolcreatedb); $this->assertFalse($role->rolcreaterole); $this->assertFalse($role->rolbypassrls); $this->assertFalse(DB::selectOne("SELECT has_database_privilege(current_user, 'sgf_tempo_dev', 'CONNECT') AS allowed")->allowed); } public function test_guard_rejects_development_before_connecting(): void { config(['database.connections.unsafe' => array_merge(config('database.connections.pgsql'), ['database' => 'sgf_tempo_dev'])]); $this->expectException(RuntimeException::class); $this->expectExceptionMessage('SGF_TEST_DATABASE_REFUSED'); TestingDatabaseGuard::assertSafe('unsafe'); } public function test_guard_rejects_connection_url_overrides(): void { config(['database.connections.unsafe' => array_merge(config('database.connections.pgsql'), ['url' => 'pgsql://invalid'])]); $this->expectException(RuntimeException::class); $this->expectExceptionMessage('SGF_TEST_DATABASE_REFUSED'); TestingDatabaseGuard::assertSafe('unsafe'); } public function test_destructive_cli_command_refuses_the_development_environment(): void { $process = new Process([PHP_BINARY, 'artisan', 'migrate:fresh', '--env=local', '--no-interaction'], base_path(), [ 'APP_ENV' => 'local', 'DB_CONNECTION' => false, 'DB_HOST' => false, 'DB_PORT' => false, 'DB_DATABASE' => false, 'DB_USERNAME' => false, 'DB_PASSWORD' => false, 'DB_URL' => false, ]); $process->run(); $this->assertFalse($process->isSuccessful()); $this->assertStringContainsString('SGF_TEST_DATABASE_REFUSED', $process->getOutput().$process->getErrorOutput()); } }