diff --git a/tests/adler_score_test.php b/tests/adler_score_test.php index 260fe1d..096d296 100644 --- a/tests/adler_score_test.php +++ b/tests/adler_score_test.php @@ -3,6 +3,7 @@ namespace local_adler; +use cm_info; use completion_info; use grade_item; use local_adler\lib\adler_testcase; @@ -44,6 +45,7 @@ class adler_score_test extends adler_testcase { private stdClass $course; private stdClass $module; private stdClass $user; + private cm_info $url_module_cm_info; public function setUp(): void { parent::setUp(); @@ -167,7 +169,7 @@ public function test_construct($test) { try { $result = new adler_score_mock($test['course_module_param'], $test['user_param']); } catch (Throwable $e) { - $this->assertEquals($test['expect_exception'], get_class($e)); + $this->assertStringContainsString($test['expect_exception'], get_class($e)); if ($test['expect_exception_message'] !== null) { $this->assertStringContainsString($test['expect_exception_message'], $e->getMessage()); } @@ -262,7 +264,7 @@ public function test_get_primitive_score(bool $completion_enabled_cm, bool $comp try { $result = $adler_score->get_score_by_completion_state(); } catch (Throwable $e) { - $this->assertEquals($expect_exception, get_class($e)); + $this->assertStringContainsString($expect_exception, get_class($e)); if ($expect_exception_message !== null) { $this->assertStringContainsString($expect_exception_message, $e->getMessage()); } diff --git a/tests/external/score_get_element_scores_test.php b/tests/external/score_get_element_scores_test.php index d0ed956..84ef613 100644 --- a/tests/external/score_get_element_scores_test.php +++ b/tests/external/score_get_element_scores_test.php @@ -173,7 +173,7 @@ public function test_execute_exceptions() { try { score_get_element_scores_mock::execute($params[$i]); } catch (Throwable $e) { - $this->assertEquals($expectExceptions[$i][0], get_class($e), '$i = ' . $i); + $this->assertStringContainsString($expectExceptions[$i][0], get_class($e), '$i = ' . $i); $this->assertStringContainsString($expectExceptions[$i][1], $e->errorcode, '$i = ' . $i); continue; } diff --git a/tests/helpers_test.php b/tests/helpers_test.php index 4dcbb32..58bc681 100644 --- a/tests/helpers_test.php +++ b/tests/helpers_test.php @@ -78,7 +78,7 @@ public function test_is_primitive_learning_element($data) { // check result if ($data['type'] == 'wrong_format') { - $this->assertEquals(moodle_exception::class, get_class($exception)); + $this->assertStringContainsString(moodle_exception::class, get_class($exception)); } else if ($exception != null) { $this->fail('Unexpected exception: ' . $exception->getMessage()); }