From da56ba898d05db3d3281b5049b4b85e3be55143e Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Wed, 1 Jun 2022 14:54:48 +0200 Subject: [PATCH] DBUtils: Introduce `setConn()` method --- library/Icinga/Util/DBUtils.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/library/Icinga/Util/DBUtils.php b/library/Icinga/Util/DBUtils.php index 6410c7ddb..067cf3779 100644 --- a/library/Icinga/Util/DBUtils.php +++ b/library/Icinga/Util/DBUtils.php @@ -37,6 +37,20 @@ class DBUtils return self::$conn; } + /** + * Set the database connection + * + * You can set the DB connection beforehand if you want, but you don't need to. You can just call + * the {@see getConn()} method if you have a valid resource factory configured. This is only used + * for the unit tests in order to allow to fake the DB connection. + * + * @param Connection $conn + */ + public static function setConn(Connection $conn): void + { + self::$conn = $conn; + } + /** * Get whether the DB connection being used is an instance of {@see Pgsql} *