From 656a05bef88cb00de5aa2ed4de418ebb0b5456f9 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Thu, 23 Apr 2020 12:20:01 +0200 Subject: [PATCH] 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. --- lib/ddl/tests/ddl_test.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/ddl/tests/ddl_test.php b/lib/ddl/tests/ddl_test.php index 061d9f11ac5..797877720e1 100644 --- a/lib/ddl/tests/ddl_test.php +++ b/lib/ddl/tests/ddl_test.php @@ -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); } }