This commit is contained in:
Andrew Nicols 2020-08-12 14:00:44 +08:00
commit 08b8b76655

View File

@ -51,6 +51,19 @@ class core_dml_testcase extends database_driver_testcase {
return $table;
}
/**
* Convert a unix string to a OS (dir separator) dependent string.
*
* @param string $source the original srting, using unix dir separators and newlines.
* @return string the resulting string, using current OS dir separators newlines.
*/
private function unix_to_os_dirsep(string $source): string {
if (DIRECTORY_SEPARATOR !== '/') {
return str_replace('/', DIRECTORY_SEPARATOR, $source);
}
return $source; // No changes, so far.
}
public function test_diagnose() {
$DB = $this->tdb;
$result = $DB->diagnose();
@ -461,7 +474,7 @@ class core_dml_testcase extends database_driver_testcase {
SELECT * FROM {users}
-- line 65 of /lib/dml/tests/fixtures/test_dml_sql_debugging_fixture.php: call to ReflectionMethod->invoke()
EOD;
$this->assertEquals($expected, $out);
$this->assertEquals($this->unix_to_os_dirsep($expected), $out);
$CFG->debugsqltrace = 2;
$out = $fixture->four($sql);
@ -470,7 +483,7 @@ SELECT * FROM {users}
-- line 65 of /lib/dml/tests/fixtures/test_dml_sql_debugging_fixture.php: call to ReflectionMethod->invoke()
-- line 74 of /lib/dml/tests/fixtures/test_dml_sql_debugging_fixture.php: call to test_dml_sql_debugging_fixture->one()
EOD;
$this->assertEquals($expected, $out);
$this->assertEquals($this->unix_to_os_dirsep($expected), $out);
$CFG->debugsqltrace = 5;
$out = $fixture->four($sql);
@ -480,9 +493,9 @@ SELECT * FROM {users}
-- line 74 of /lib/dml/tests/fixtures/test_dml_sql_debugging_fixture.php: call to test_dml_sql_debugging_fixture->one()
-- line 83 of /lib/dml/tests/fixtures/test_dml_sql_debugging_fixture.php: call to test_dml_sql_debugging_fixture->two()
-- line 92 of /lib/dml/tests/fixtures/test_dml_sql_debugging_fixture.php: call to test_dml_sql_debugging_fixture->three()
-- line 476 of /lib/dml/tests/dml_test.php: call to test_dml_sql_debugging_fixture->four()
-- line 489 of /lib/dml/tests/dml_test.php: call to test_dml_sql_debugging_fixture->four()
EOD;
$this->assertEquals($expected, $out);
$this->assertEquals($this->unix_to_os_dirsep($expected), $out);
$CFG->debugsqltrace = 0;
}