From 831c7e66ec218aac1e9f80576fde6ec7cc77f59e Mon Sep 17 00:00:00 2001
From: djarrancotleanu <djarrancotleanu@catalyst-au.net>
Date: Tue, 13 Feb 2024 18:08:55 +1000
Subject: [PATCH] Fix core unit tests failing

---
 filter/kaltura/db/install.php | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/filter/kaltura/db/install.php b/filter/kaltura/db/install.php
index 287bab3f..83b7934b 100644
--- a/filter/kaltura/db/install.php
+++ b/filter/kaltura/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);
+    }
+
 }