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).
This commit is contained in:
Eloy Lafuente (stronk7)
2014-03-31 09:30:27 +08:00
committed by Petr Škoda
parent 64b18f75b9
commit dd693b76fa
2 changed files with 10 additions and 2 deletions
+5 -1
View File
@@ -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');
}
+5 -1
View File
@@ -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');
}