From b8a9f84b0a212ce18c8a4ac5cceef79d1c8ac115 Mon Sep 17 00:00:00 2001 From: David Watson <14983002+watson8@users.noreply.github.com> Date: Mon, 28 Oct 2024 16:32:30 +0000 Subject: [PATCH] CTP-3783 phpunit build fails --- lib.php | 2 +- tests/generator_test.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib.php b/lib.php index 2caad79..e679979 100644 --- a/lib.php +++ b/lib.php @@ -938,7 +938,7 @@ function coursework_get_coursework_ids_from_context_id($contextid) { $coursemodule = get_coursemodule_from_id('coursework', $context->instanceid); $courseworkmoduleid = $DB->get_field('modules', 'id', ['name' => 'coursework']); - if ($coursemodule->module == $courseworkmoduleid) { + if ($coursemodule && $coursemodule->module == $courseworkmoduleid) { $courseworkids[] = $coursemodule->instance; } break; diff --git a/tests/generator_test.php b/tests/generator_test.php index 1877f5e..b58cbe7 100644 --- a/tests/generator_test.php +++ b/tests/generator_test.php @@ -46,6 +46,10 @@ final class generator_test extends \advanced_testcase { */ public function setUp(): void { $this->resetAfterTest(true); + // If we don't do this, we end up with the same cached objects for all tests and they may have incorrect/missing properties. + \mod_coursework\models\coursework::$pool = null; + \mod_coursework\models\course_module::$pool = null; + \mod_coursework\models\module::$pool = null; } /**