moodle-logstore_xapi
moodle-logstore_xapi copied to clipboard
Unit test failure in core moodle 3.6 test_deprecated_course_module_instances_list_viewed_events
Description
- This plugin causes a core moodle unit test to fail.
Version
- master branch in this repo with composer install command run as described in git install readme:
php -r "readfile('https://getcomposer.org/installer');" | php; rm -rf vendor; php composer.phar install --prefer-source
Steps to reproduce the bug
- Set up a clean moodle 3.6 and install this plugin, master branch.
- Run
vendor/bin/phpunit --testsuite=core_testsuite --stop-on-failure - Observe the error:
There was 1 failure:
- core_event_deprecated_testcase::test_deprecated_course_module_instances_list_viewed_events Expectation failed, debugging() not triggered.
/siteroot/lib/phpunit/classes/advanced_testcase.php:295 /siteroot/lib/tests/event_deprecated_test.php:42 /siteroot/lib/phpunit/classes/advanced_testcase.php:80
To re-run: vendor/bin/phpunit "core_event_deprecated_testcase" lib/tests/event_deprecated_test.php
FAILURES! Tests: 454, Assertions: 26217, Failures: 1.
Expected behaviour
- The plugin should not break core moodle tests (the tests pass when the plugin isn't there)
Additional Information The plugin might be having a weird effect on moodle's class autoloading. Has this error been seen by anyone before?
Server information PHP 7.2.19-0ubuntu0.18.04.1
Hi @kristian-94 - thanks for reporting this! I've confirmed that this is the case on Moodle 3.8.1. Will begin investigating. Since you submitted this, have you discovered anything further?
sorry @davidpesce , I haven't looked into it further
Quick update on this. If you run the test independently it passes.
davidpesce@mbp moodle-docker % bin/moodle-docker-compose exec webserver vendor/bin/phpunit "core_event_deprecated_testcase" lib/tests/event_deprecated_test.php
Moodle 3.8.1+ (Build: 20200124), 85a035b1c5bb9e302bc779c2e6d8f449f6db5e61
Php: 7.2.27, pgsql: 11.6 (Debian 11.6-1.pgdg90+1), OS: Linux 4.19.76-linuxkit x86_64
PHPUnit 7.5.17 by Sebastian Bergmann and contributors.
. 1 / 1 (100%)
Time: 4.54 seconds, Memory: 38.00 MB
with every call to src\transformer\get_event_function_map()
core\event\content_viewed has been deprecated.
core\event\course_module_instances_list_viewed has been deprecated.
core\event\message_contact_blocked has been deprecated.
core\event\message_contact_unblocked has been deperecated.
core\event\role_capabilities_updated has been deprecated.
mod_lesson\event\highscore_added has been deprecated.
mod_lesson\event\highscores_viewed has been deprecated.
Moodle 3.8.2+ (Build: 20200327) Php: 7.3.16.1.18.04.1.1
Confirmed that the deprecated message is causing this issue. Later versions of Moodle have removed the events and it's causing an exception. Related issues: #805 and #812
After a bit more digging, found an explanation here: https://github.com/xAPI-vle/moodle-logstore_xapi/commit/243694f392f3429cf92fff7a6254fed1cf4eb2d2
Copying from above: "In unit test, if test_adminroot_cache_reset test is run before core_event_deprecated_testcase the report_eventlist_list_generator will load course_module_instances_list_viewed abstract class which will cause the core_event_deprecated_testcase to fail (debugging already called and the debug mode is off - list_generator.php)"
It doesn't look like there's a way to ignore events that are deprecated: https://github.com/moodle/moodle/blob/9145d80b0b89794c97cc9aeb6257a1802bd1b58d/report/eventlist/classes/list_generator.php#L42
Submitted a tracker issue to Moodle. Unfortunately, we don't have the ability to change core behavior.