implement new version of MessageFilter derived from forte and add some more tests

This commit is contained in:
Mario Vavti
2025-12-12 12:42:01 +01:00
parent 16068af0bb
commit 48dbba2f4d
9 changed files with 488 additions and 256 deletions

View File

@@ -37,7 +37,7 @@ class MessageFilterTest extends UnitTestCase {
'created' => '2025-04-18 20:50:00'
];
$this->assertEquals($result, MessageFilter::evaluate($item, $incl, $excl));
$this->assertEquals($result, (new MessageFilter($item, $incl, $excl))->evaluate());
}
public static function evaluate_provider() : array {
@@ -62,6 +62,11 @@ class MessageFilterTest extends UnitTestCase {
'',
true
],
'lang!=en in excl' => [
'',
'lang!=en',
true
],
'lang=en in excl' => [
'',
'lang=en',
@@ -202,6 +207,47 @@ class MessageFilterTest extends UnitTestCase {
'',
true
],
// provided by issue #1957
'item is public, and item is not a comment' => [
'?item_private > 0 || ?item_thread_top == 0',
'',
false
],
'body does not contain any of two keywords in incl' => [
'?body ~= rosencrantz || ?body ~= guildenstern',
'',
false
],
'body does not contain keyword in incl, item is public, item is not a comment' => [
'?body ~= rosencrantz || ?item_private > 0 || ?item_thread_top == 0',
'',
false
],
'body does not contain any of two keywords in incl, item is public, item is not a comment' => [
'?body ~= rosencrantz || ?body ~= guildenstern || ?item_private > 0 || ?item_thread_top == 0',
'',
false
],
'item is public, and item is not a comment, repeat in excl' => [
'?item_private > 0 || ?item_thread_top == 0',
'?verb == Announce',
false
],
'body does not contain any of two keywords in incl, repeat in excl' => [
'?body ~= rosencrantz || ?body ~= guildenstern',
'?verb == Announce',
false
],
'body does not contain keyword in incl, item is public, item is not a comment, repeat in excl' => [
'?body ~= rosencrantz || ?item_private > 0 || ?item_thread_top == 0',
'?verb == Announce',
false
],
'body does not contain any of two keywords in incl, item is public, item is not a comment, repeat in excl' => [
'?body ~= rosencrantz || ?body ~= guildenstern || ?item_private > 0 || ?item_thread_top == 0',
'?verb == Announce',
false
],
];
}
}