There are no unit tests in AbuseFilter at the moment. Even phpTest.php has to be called manually. There should be a test suite that simulates common uses.
Basic tests to implement:
- Tests for all AFPUserVisibleException exceptions (https://gerrit.wikimedia.org/r/#/c/443210/)
- Tests for filter validation (https://gerrit.wikimedia.org/r/#/c/443520/)
- Tests for generic functions in AbuseFilter class (https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/AbuseFilter/+/444191/)
- Complete tests where filters are created, actions are executed and consequences must be taken. (https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/AbuseFilter/+/444442/)
See Also:
Examples of filters broken by updates:
- T52107: Variable added_lines is now an array instead of a string
- T54053: AbuseFilter doesn't set any of the "moved_to..." variables anymore
- T73947: Edits via API (e.g. through VisualEditor) cause AbuseFilter to work on pre-automerged edit / T76063: Mismatch between new page text seen by AbuseFilter and actual new page content
- T74329: "added_lines" is not in "new_wikitext" anymore and causes false positives
- T100069: added_lines include whitespace at the beginning
- T100249: AbuseFilter adds spaces before "added_lines", causing many false positives