MDL-67886 phpunit: Make tests cross-db

The suggested SQL in some of the assertions was not cross-db
but db-dependent. Now we just keep that part out from the
assertions, because it's not important to verify the
errors that are being asserted.
This commit is contained in:
Eloy Lafuente (stronk7)
2020-04-23 12:30:17 +02:00
parent 801c9c2717
commit 656a05bef8
+5 -4
View File
@@ -2410,13 +2410,14 @@ class core_ddl_testcase extends database_driver_testcase {
// 3. Missing indexes.
// 4. Extra columns.
$errors = $dbmanager->check_database_schema($schema)['test_check_db_schema'];
$strmissing = "Missing index 'missingkey' (not unique (courseid)). " . PHP_EOL .
"CREATE INDEX {$CFG->prefix}testchecdbsche_cou_ix ON {$CFG->prefix}test_check_db_schema (courseid);";
// Preprocess $errors to get rid of the non compatible (SQL-dialect dependent) parts.
array_walk($errors, function(&$error) {
$error = trim(strtok($error, PHP_EOL));
});
$this->assertCount(4, $errors);
$this->assertContains("column 'courseid' has incorrect type 'I', expected 'N'", $errors);
$this->assertContains("column 'missingcolumn' is missing", $errors);
$this->assertContains($strmissing, $errors);
$this->assertContains("Missing index 'missingkey' (not unique (courseid)).", $errors);
$this->assertContains("column 'extracolumn' is not expected (I)", $errors);
}
}