From d9a8eb2bdbc7d51630b465784a2281d7a76c8a14 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Sun, 7 Apr 2024 23:31:26 +0800 Subject: [PATCH 1/2] MDL-81457 core: Mark SSL test as skipped, not incomplete The incomplete test is intended for tests which are written but whose code does not yet exist. https://docs.phpunit.de/en/9.6/incomplete-and-skipped-tests.html --- lib/dml/tests/mysqli_native_moodle_database_test.php | 3 ++- lib/dml/tests/pgsql_native_moodle_database_test.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/dml/tests/mysqli_native_moodle_database_test.php b/lib/dml/tests/mysqli_native_moodle_database_test.php index dd17338224a..565ee41c266 100644 --- a/lib/dml/tests/mysqli_native_moodle_database_test.php +++ b/lib/dml/tests/mysqli_native_moodle_database_test.php @@ -122,7 +122,8 @@ class mysqli_native_moodle_database_test extends \advanced_testcase { } catch (moodle_exception $e) { // ... or fail. // Unfortunately we cannot be sure with the error string. - $this->markTestIncomplete('SSL not supported?'); + $this->markTestSkipped('MySQL server does not support SSL. Unable to complete the test.'); + return; } try { diff --git a/lib/dml/tests/pgsql_native_moodle_database_test.php b/lib/dml/tests/pgsql_native_moodle_database_test.php index 3e0a32e5546..09e6030391d 100644 --- a/lib/dml/tests/pgsql_native_moodle_database_test.php +++ b/lib/dml/tests/pgsql_native_moodle_database_test.php @@ -409,7 +409,8 @@ class pgsql_native_moodle_database_test extends \advanced_testcase { // ... or fail with SSL not supported. $this->assertStringContainsString($pgconnerr, $e->debuginfo); $this->assertStringContainsString('server does not support SSL', $e->debuginfo); - $this->markTestIncomplete('SSL not supported.'); + $this->markTestSkipped('Postgres server does not support SSL. Unable to complete the test.'); + return; } try { From 5b9fdc0e9a8c8c1e006e67b00c79f4db4bf244f2 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Sun, 7 Apr 2024 23:31:26 +0800 Subject: [PATCH 2/2] MDL-81457 core: Do not mark tests as Incomplete when they are wrong This check was marking a test as Incomplete if there was a bug in any part of the test, rather than failing the test in such a way that the test bug may be found. https://docs.phpunit.de/en/9.6/incomplete-and-skipped-tests.html --- enrol/tests/externallib_test.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/enrol/tests/externallib_test.php b/enrol/tests/externallib_test.php index d5ebb5dce87..c81ac56a143 100644 --- a/enrol/tests/externallib_test.php +++ b/enrol/tests/externallib_test.php @@ -328,8 +328,9 @@ class externallib_test extends externallib_advanced_testcase { $this->expectExceptionMessage($exception['message']); } else { // Failed, only canview and exception are supported. - $this->markTestIncomplete('Incomplete, only canview and exception are supported'); + throw new \coding_exception('Incomplete, only canview and exception are supported'); } + // Switch to the user and assign the role. $this->setUser(${$user}); role_assign($roleid, $USER->id, $coursecontext);