Page MenuHomePhabricator

Make SummaryFormatterTest a proper unit test
Closed, ResolvedPublic

Description

The SummaryFormatterTest service wiring test currently fails when run as a pure unit test because OutputFormatSnakFormatterFactory::getSnakFormatter() uses wfMessage(). We should fix that.

In general, wfMessage() is tricky to replace in service wiring because it depends on the user language, which we don’t want to use in services (compare T279415: Remove calls to deprecated WikibaseRepo::getUserLanguage). However, in this case it actually wants a message in a specific language, so I think we can create a new service (e.g. MessageInLanguageProvider), similar to MessageLocalizer but agnostic of the user language, and use that.

Event Timeline

Change 684299 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/Wikibase@master] Introduce MessageInLanguageProvider service

https://gerrit.wikimedia.org/r/684299

Change 684299 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Introduce MessageInLanguageProvider service

https://gerrit.wikimedia.org/r/684299

$ vendor/bin/phpunit extensions/Wikibase/repo/tests/phpunit/unit/ServiceWiring/SummaryFormatterTest.php 
PHPUnit 8.5.15 by Sebastian Bergmann and contributors.

.                                                                   1 / 1 (100%)

Time: 133 ms, Memory: 20.00 MB

OK (1 test, 28 assertions)