Commit a20d6752 authored by Tim Hunt's avatar Tim Hunt
Browse files

MDL-47666 DB auth & enrol: unit tests fail with custom DB drivers

Changed to used $DB->get_db_family, rather than hard-coding the list of
class names.
parent b49de5d9
......@@ -52,14 +52,9 @@ class auth_db_testcase extends advanced_testcase {
set_config('host', $CFG->dbhost.':'.$CFG->dboptions['dbport'], 'auth/db');
}
switch (get_class($DB)) {
case 'mssql_native_moodle_database':
set_config('type', 'mssql_n', 'auth/db');
set_config('sybasequoting', '1', 'auth/db');
break;
switch ($DB->get_dbfamily()) {
case 'mariadb_native_moodle_database':
case 'mysqli_native_moodle_database':
case 'mysql':
set_config('type', 'mysqli', 'auth/db');
set_config('setupsql', "SET NAMES 'UTF-8'", 'auth/db');
set_config('sybasequoting', '0', 'auth/db');
......@@ -72,12 +67,12 @@ class auth_db_testcase extends advanced_testcase {
}
break;
case 'oci_native_moodle_database':
case 'oracle':
set_config('type', 'oci8po', 'auth/db');
set_config('sybasequoting', '1', 'auth/db');
break;
case 'pgsql_native_moodle_database':
case 'postgres':
set_config('type', 'postgres7', 'auth/db');
$setupsql = "SET NAMES 'UTF-8'";
if (!empty($CFG->dboptions['dbschema'])) {
......@@ -98,13 +93,17 @@ class auth_db_testcase extends advanced_testcase {
}
break;
case 'sqlsrv_native_moodle_database':
set_config('type', 'mssqlnative', 'auth/db');
case 'mssql':
if (get_class($DB) == 'mssql_native_moodle_database') {
set_config('type', 'mssql_n', 'auth/db');
} else {
set_config('type', 'mssqlnative', 'auth/db');
}
set_config('sybasequoting', '1', 'auth/db');
break;
default:
throw new exception('Unknown database driver '.get_class($DB));
throw new exception('Unknown database family ' . $DB->get_dbfamily());
}
$table = new xmldb_table('auth_db_users');
......
......@@ -54,14 +54,9 @@ class enrol_database_testcase extends advanced_testcase {
set_config('dbhost', $CFG->dbhost.':'.$CFG->dboptions['dbport'], 'enrol_database');
}
switch (get_class($DB)) {
case 'mssql_native_moodle_database':
set_config('dbtype', 'mssql_n', 'enrol_database');
set_config('dbsybasequoting', '1', 'enrol_database');
break;
switch ($DB->get_dbfamily()) {
case 'mariadb_native_moodle_database':
case 'mysqli_native_moodle_database':
case 'mysql':
set_config('dbtype', 'mysqli', 'enrol_database');
set_config('dbsetupsql', "SET NAMES 'UTF-8'", 'enrol_database');
set_config('dbsybasequoting', '0', 'enrol_database');
......@@ -74,12 +69,12 @@ class enrol_database_testcase extends advanced_testcase {
}
break;
case 'oci_native_moodle_database':
case 'oracle':
set_config('dbtype', 'oci8po', 'enrol_database');
set_config('dbsybasequoting', '1', 'enrol_database');
break;
case 'pgsql_native_moodle_database':
case 'postgres':
set_config('dbtype', 'postgres7', 'enrol_database');
$setupsql = "SET NAMES 'UTF-8'";
if (!empty($CFG->dboptions['dbschema'])) {
......@@ -100,8 +95,12 @@ class enrol_database_testcase extends advanced_testcase {
}
break;
case 'sqlsrv_native_moodle_database':
set_config('dbtype', 'mssqlnative', 'enrol_database');
case 'mssql':
if (get_class($DB) == 'mssql_native_moodle_database') {
set_config('dbtype', 'mssql_n', 'enrol_database');
} else {
set_config('dbtype', 'mssqlnative', 'enrol_database');
}
set_config('dbsybasequoting', '1', 'enrol_database');
break;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment