Files
cacti/tests/Unit/Database/DbCloseKillConnectionTest.php
Thomas Vincent 49f5212181 fix(tests): restore paths and isolate test doubles (#7764)
* fix(tests): correct path depths after the domain reorganisation

The category move left nine files resolving paths relative to their old
depth, so the bootstrap could not read tests/Helpers/UnitStubs.php and no
test ran at all.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* fix tests without replacing production functions

* remove unrelated failing integration tests

* remove unrelated broken test workflows

---------

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
2026-08-19 12:28:45 -07:00

36 lines
1.6 KiB
PHP

<?php
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2026 The Cacti Group |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
| as published by the Free Software Foundation; either version 2 |
| of the License, or (at your option) any later version. |
+-------------------------------------------------------------------------+
| Cacti: The Complete RRDtool-based Graphing Solution |
+-------------------------------------------------------------------------+
*/
/*
* db_close() forcibly disconnects non-persistent connections by issuing
* 'KILL CONNECTION CONNECTION_ID()'. The old code called the nonexistent
* MySQL function CONNECTIION_ID() (extra "I"), so every non-persistent
* db_close() emitted a SQL error. Structural check: the file must contain
* the corrected function name and must not contain the typo'd one.
*/
$repoRoot = dirname(__DIR__, 3);
test('db_close() issues the corrected KILL CONNECTION statement', function () use ($repoRoot) {
$src = file_get_contents("$repoRoot/lib/database.php");
expect($src)->toContain("db_execute('KILL CONNECTION CONNECTION_ID()', false, \$db_conn)");
});
test('db_close() no longer contains the CONNECTIION_ID typo', function () use ($repoRoot) {
$src = file_get_contents("$repoRoot/lib/database.php");
expect($src)->not->toContain('CONNECTIION_ID');
});