From dd693b76faffb8e97cfcb2bd96b89583f81b5e11 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Sun, 30 Mar 2014 22:32:25 +0200 Subject: [PATCH] MDL-44862 postgres: tests to support socket & port Both the database auth and enrol plugins use ADOdb to perform connections. Socket and port are allowed there if passed as "socket:port", so, when both are configured in CFG, we pass them that way. Else ADOdb defaults to standard port (5432). --- auth/db/tests/db_test.php | 6 +++++- enrol/database/tests/sync_test.php | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/auth/db/tests/db_test.php b/auth/db/tests/db_test.php index 1be135507b7..bb48fe07750 100644 --- a/auth/db/tests/db_test.php +++ b/auth/db/tests/db_test.php @@ -80,7 +80,11 @@ class auth_db_testcase extends advanced_testcase { set_config('sybasequoting', '0', 'auth/db'); if (!empty($CFG->dboptions['dbsocket']) and ($CFG->dbhost === 'localhost' or $CFG->dbhost === '127.0.0.1')) { if (strpos($CFG->dboptions['dbsocket'], '/') !== false) { - set_config('host', $CFG->dboptions['dbsocket'], 'auth/db'); + $socket = $CFG->dboptions['dbsocket']; + if (!empty($CFG->dboptions['dbport'])) { + $socket .= ':' . $CFG->dboptions['dbport']; + } + set_config('host', $socket, 'auth/db'); } else { set_config('host', '', 'auth/db'); } diff --git a/enrol/database/tests/sync_test.php b/enrol/database/tests/sync_test.php index 014de06ee3c..2505b0e482a 100644 --- a/enrol/database/tests/sync_test.php +++ b/enrol/database/tests/sync_test.php @@ -81,7 +81,11 @@ class enrol_database_testcase extends advanced_testcase { set_config('dbsybasequoting', '0', 'enrol_database'); if (!empty($CFG->dboptions['dbsocket']) and ($CFG->dbhost === 'localhost' or $CFG->dbhost === '127.0.0.1')) { if (strpos($CFG->dboptions['dbsocket'], '/') !== false) { - set_config('dbhost', $CFG->dboptions['dbsocket'], 'enrol_database'); + $socket = $CFG->dboptions['dbsocket']; + if (!empty($CFG->dboptions['dbport'])) { + $socket .= ':' . $CFG->dboptions['dbport']; + } + set_config('dbhost', $socket, 'enrol_database'); } else { set_config('dbhost', '', 'enrol_database'); }