4 * A simple {@link MessageLocalizer} implementation for use in tests.
5 * By default, it sets the message language to 'qqx',
6 * to make the tests independent of the wiki configuration.
8 * @author Lucas Werkmeister
9 * @license GPL-2.0-or-later
11 class MockMessageLocalizer
implements MessageLocalizer
{
16 private $languageCode;
19 * @param string|null $languageCode The language code to use for messages by default.
20 * You can specify null to use the user language,
21 * but this is not recommended as it may make your tests depend on the wiki configuration.
23 public function __construct( $languageCode = 'qqx' ) {
24 $this->languageCode
= $languageCode;
28 * Get a Message object.
29 * Parameters are the same as {@link wfMessage()}.
31 * @param string|string[]|MessageSpecifier $key Message key, or array of keys,
32 * or a MessageSpecifier.
33 * @param mixed ...$params
36 public function msg( $key, ...$params ) {
37 $message = wfMessage( $key, ...$params );
39 if ( $this->languageCode
!== null ) {
40 $message->inLanguage( $this->languageCode
);