assertNotEmpty($this->app['db']->getConnections(), '쿼리 후 연결이 열려 있어야 합니다'); $this->purgeIdleDatabaseConnections(); $this->assertSame([], $this->app['db']->getConnections(), '유휴 연결은 모두 닫혀야 합니다'); } #[Test] public function transacting_connection_survives_purge(): void { DB::beginTransaction(); try { $this->purgeIdleDatabaseConnections(); // 트랜잭션 진행 중 연결은 보존 — 트레이트의 롤백 콜백이 담당한다 $this->assertArrayHasKey( DB::getDefaultConnection(), $this->app['db']->getConnections(), '트랜잭션 진행 중인 연결은 purge 대상이 아니어야 합니다', ); $this->assertSame(1, DB::connection()->transactionLevel()); } finally { DB::rollBack(); } } }