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-30 22:32:25 +02:00 committed by Petr Škoda
parent 96255f472c
commit 6576413e48
2 changed files with 10 additions and 2 deletions

View File

@ -87,7 +87,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');
}

View File

@ -89,7 +89,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');
}