Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kaltura filter causes core unit test to fail in Moodle 3.11 and 4.0 #394

Open
golenkovm opened this issue Jan 19, 2023 · 1 comment
Open

Comments

@golenkovm
Copy link

When running unit tests with filter_kaltura plugin installed the following core test is failing:

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

/var/www/site/course/tests/externallib_test.php:2756
/var/www/site/lib/phpunit/classes/advanced_testcase.php:80
phpvfscomposer:///var/www/site/vendor/phpunit/phpunit/phpunit:97

It seems like it expects a specific number of filters enabled by default.

@golenkovm
Copy link
Author

The following patch was applied to fix the issue, but feel free to implement the fix in your own way:

diff --git a/db/install.php b/db/install.php
index 287bab3..83b7934 100644
--- a/db/install.php
+++ b/db/install.php
@@ -25,5 +25,10 @@ function xmldb_filter_kaltura_install() {
     global $CFG;
     require_once("$CFG->libdir/filterlib.php");
 
-    filter_set_global_state('kaltura', TEXTFILTER_ON);
+    // Do not enable the filter when running unit tests because some core
+    // tests expect a specific number of filters enabled.
+    if (!defined('PHPUNIT_TEST') || !PHPUNIT_TEST) {
+        filter_set_global_state('kaltura', TEXTFILTER_ON);
+    }
+
 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant