FormulasQuestion / moodle-qtype_formulas

Formulas question type for Moodle
18 stars 30 forks source link

Unit tests are failing on MOODLE_39_STABLE branch #81

Closed golenkovm closed 1 year ago

golenkovm commented 1 year ago

Running Moodle 3.9 unit tests and having the following issues:

There were 4 failures:

1) qtype_formulas_variables_test::test_evaluate_general_expression
Failed asserting that -0.35473297204849324 matches expected -0.35473297204849.

/var/www/site/question/type/formulas/tests/variables_test.php:79
/var/www/site/lib/phpunit/classes/advanced_testcase.php:85

To re-run:
 vendor/bin/phpunit "qtype_formulas_variables_test" question/type/formulas/tests/variables_test.php

2) qtype_formulas_variables_test::test_evaluate_assignments_1
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
     'g' => stdClass Object (
         'type' => 'ln'
         'value' => Array (
-            0 => 1
-            1 => 47
-            2 => 2
-            3 => 2.718281828459
-            4 => 16
+            0 => 1.0
+            1 => 47.0
+            2 => 2.0
+            3 => 2.718281828459045
+            4 => 16.0
         )
     )
 )

/var/www/site/question/type/formulas/tests/variables_test.php:158
/var/www/site/lib/phpunit/classes/advanced_testcase.php:85

To re-run:
 vendor/bin/phpunit "qtype_formulas_variables_test" question/type/formulas/tests/variables_test.php

3) qtype_formulas_variables_test::test_evaluate_assignments_3
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
     'A' => stdClass Object (
         'type' => 'ln'
         'value' => Array (
-            0 => 2.718281828459
-            1 => 7.3890560989307
-            2 => 20.085536923188
+            0 => 2.718281828459045
+            1 => 7.38905609893065
+            2 => 20.085536923187668
         )
     )
 )

/var/www/site/question/type/formulas/tests/variables_test.php:461
/var/www/site/lib/phpunit/classes/advanced_testcase.php:85

To re-run:
 vendor/bin/phpunit "qtype_formulas_variables_test" question/type/formulas/tests/variables_test.php

4) qtype_formulas_variables_test::test_numerical_formula_2
Failed asserting that 51.7392700412041 matches expected 51.739270041204.

/var/www/site/question/type/formulas/tests/variables_test.php:642
/var/www/site/lib/phpunit/classes/advanced_testcase.php:85

To re-run:
 vendor/bin/phpunit "qtype_formulas_variables_test" question/type/formulas/tests/variables_test.php

This seems to be already fixed in master branch, see https://github.com/FormulasQuestion/moodle-qtype_formulas/commit/d5ec6c240bc7824f3a82db9f1bd361be1ca6df86 . It would be great to have this fixed in MOODLE_39_STABLE branch too.

3.9 LTS version of Moodle still supports security updates till 11 December 2023. In practice that means that many slow moving organisations (especially universities) are most likely stay on 3.9 for a bit longer than bug fixing period. If you had a chance to have the patch backported that would be much appreciated.

I'm more than happy to make a PR for this.

Cheers, Misha

golenkovm commented 1 year ago

It looks like there is one more failure in 3.9:

root@92f828811309:/var/www/site# vendor/bin/phpunit --testsuite='qtype_formulas_testsuite'
Moodle 3.9.19+ (Build: 20230224), 05f31771a91d5c227e5f85940c6cf541de55d2b9
Php: 7.4.33, pgsql: 12.8 (Debian 12.8-1.pgdg110+1), OS: Linux 5.15.0-60-generic x86_64
PHPUnit 7.5.20 by Sebastian Bergmann and contributors.

.....................................F.................           55 / 55 (100%)

Time: 3.43 seconds, Memory: 115.00 MB

There was 1 failure:

1) qtype_formulas_test::test_get_question_options
Failed asserting that actual size 1 matches expected size 4.

/var/www/site/question/type/formulas/tests/questiontype_test.php:200
/var/www/site/lib/phpunit/classes/advanced_testcase.php:85
phpvfscomposer:///var/www/site/vendor/phpunit/phpunit/phpunit:60

To re-run:
 vendor/bin/phpunit "qtype_formulas_test" question/type/formulas/tests/questiontype_test.php

FAILURES!
Tests: 55, Assertions: 731, Failures: 1.

Which appears to be fixed by https://github.com/FormulasQuestion/moodle-qtype_formulas/commit/243d0a1e7be27796a74e08f8000a1595217b05c0 in master. I will add this commit to my PR

PhilippImhof commented 1 year ago

Thanks for reporting this. Please note that those branches are legacy stuff. The master branch and current release has full support for Moodle 3.9, as indicated in the README file.