Core MediaWiki has code for simple grammar transformations for cases, which should be more data-driven and common to PHP and JS (see T115217).
In particular, since the logic is supposed to be the same in PHP and Js, so should be the tests. Currently they have to be implemented separately as PHP and JS code, which makes adding new rules very uncomfortable. In fact, as of this writing, the test cases are not in sync, which is definitely an issue.
These tests should be moved to a separate data file (probably JSON). The data is there already in mediawiki.language.test.js, so it needs to be moved from that JS file to JSON with changes for JSON syntax, and the missing rules from the PHP tests must be added. That's the easy part.
The (somewhat) harder part is making it loadable in phpunit and Qunit tests. It's probably easy to just read the files in PHP, but I couldn't find a way to load such files to Qunit tests; it will probably require a new kind of ResourceLoader module (but it's quite possible that I didn't look well enough).
This should also make it possible to run these unit tests in CI for all the languages rather than only English.