commands[] = $command; if ($command === 'system-database:verify') { throw new RuntimeException('candidate failed'); } } }; try { $configuration->persist([ 'host' => 'shared-db.test', 'port' => 3306, 'database' => 'shared_system', 'username' => 'shared_writer', 'password' => 'shared-secret', 'prefix' => 'ak_', 'tls_required' => true, 'tls_verify_server_cert' => false, 'tls_ca' => '', ]); $this->fail('验证失败时应抛出异常。'); } catch (RuntimeException $exception) { $this->assertSame('新配置未通过应用级验证,已自动恢复原系统数据库。', $exception->getMessage()); $this->assertSame($original, file_get_contents($environmentPath)); $this->assertSame(['system-database:verify', 'app:ready'], $configuration->commands); } finally { @unlink($environmentPath); } } }