branchup / moodle-filter_shortcodes

Enables users to easily inject and modify content using shortcodes provided by other Moodle plugins.
14 stars 8 forks source link

The plugin shouldn't be installed by default when running PHPUnit tests #3

Closed dmitriim closed 3 years ago

dmitriim commented 3 years ago

The plugin shouldn't be installed by default when running PHPUnit tests. Otherwise it breaks core tests. See below.

root@31c07ba26f79:/var/www/site#  vendor/bin/phpunit "core_course_externallib_testcase" course/tests/externallib_test.php
Moodle 3.9.10+ (Build: 20211003), 5f2f9830b5a43723bc7829d140a29c8d4152084a
Php: 7.4.3, pgsql: 10.15 (Debian 10.15-1.pgdg90+1), OS: Linux 5.11.0-27-generic x86_64
PHPUnit 7.5.20 by Sebastian Bergmann and contributors.

............................................F.................... 65 / 80 ( 81%)
...............                                                   80 / 80 (100%)

Time: 30.99 seconds, Memory: 115.00 MB

There was 1 failure:

1) core_course_externallib_testcase::test_get_courses_by_field
Failed asserting that actual size 7 matches expected size 6.

/var/www/site/course/tests/externallib_test.php:2516
/var/www/site/lib/phpunit/classes/advanced_testcase.php:80

To re-run:
 vendor/bin/phpunit "core_course_externallib_testcase" course/tests/externallib_test.php

FAILURES!
Tests: 80, Assertions: 628, Failures: 1.
root@31c07ba26f79:/var/www/site# 
FMCorz commented 3 years ago

Hi @dmitriim,

Thank you for reporting this, and for providing a patch.

Arguably, the core test should ignore 3rd party filters when performing its check, however we agree with the solution you provided in #4, and will merge it shortly. Disabling automatic enabling during unit tests only seems like the right way forward.

Thank you!

dmitriim commented 3 years ago

thanks @FMCorz that was very quick!