MDL-75757 phpunit: Add some tolerance to a few failing assertions

Recently, PHPUnit (all versions) did some changes about how the
comparators worked and this has caused some float comparisons
to stop working.

We need to move them to assertEqualsWithDelta(), allowing a small
tolerance to workaround the floats comparison problem.

0.00001 has been decided. And applied to all the similar assertions
within the unittest function, so if more cases are added to them
better be copied with the agreed tolerance.
This commit is contained in:
Eloy Lafuente (stronk7)
2022-09-18 15:55:36 +02:00
parent b077af7e89
commit 6be384ee8f
3 changed files with 15 additions and 8 deletions
+5
View File
@@ -480,6 +480,11 @@ abstract class data_loading_method_test_base extends advanced_testcase {
abstract class question_testcase extends advanced_testcase {
/**
* Tolerance accepted in some unit tests when float operations are involved.
*/
const GRADE_DELTA = 0.00000005;
public function assert($expectation, $compare, $notused = '') {
if (get_class($expectation) === 'question_pattern_expectation') {