Wunderbyte-GmbH / moodle-mod_booking

Moodle Booking Module
https://www.wunderbyte.at
21 stars 39 forks source link

PHPUnit Test Failure in adminlib_test.php on Moodle 4.4.1 #553

Open rajandangi opened 3 months ago

rajandangi commented 3 months ago

Description A PHPUnit test failure occurs in adminlib_test.php when running tests with Moodle version 4.4.1. The failure is related to asserting that two arrays are identical in the test_admin_apply_default_settings method.

Versions uses

To Reproduce

  1. Run PHPUnit tests using the command: vendor/bin/phpunit lib/tests/adminlib_test.php

Expected behavior All tests should pass without any failures.

Actual Behavior

The test `core\adminlib_test::test_admin_apply_default_settings` fails due to an unexpected array difference:
```diff
--- Expected
+++ Actual
@@ @@
-Array &0 ()
+Array &0 (
+    'booking/defaulttemplate' => '1'
+)

Additional context This issue might be related to default settings not being applied as expected within the test environment.


Please investigate the cause of this failure and provide a fix or workaround to ensure all tests pass successfully.

rajandangi commented 3 months ago

The issue seems to be caused by the code segment in settings.php:

Since $alloptiontemplates is not available during installation, the default value of 1 forbooking/defaulttemplate causes the test to fail.

Can we set the default value to 0 instead of 1 to prevent this error during installation?

Is there any particular reason for setting the default value to 1?

georgmaisser commented 3 months ago

We will look into this. We really need to add Moodle 4.4 to our standard test routine... Thank you for your investigation. I wouldn't see a reason why this would indicate a major problem...

rajandangi commented 3 months ago

This has recently been added to the Moodle core, which is why it is causing the problem. https://github.com/moodle/moodle/commit/92446838abd56607e0ad5440005907f3a3892193