8 * A simple {@link MessageLocalizer} implementation for use in tests.
9 * By default, it sets the message language to 'qqx',
10 * to make the tests independent of the wiki configuration.
12 * @author Lucas Werkmeister
13 * @license GPL-2.0-or-later
15 class MockMessageLocalizer
implements MessageLocalizer
{
20 private $languageCode;
23 * @param string|null $languageCode The language code to use for messages by default.
24 * You can specify null to use the user language,
25 * but this is not recommended as it may make your tests depend on the wiki configuration.
27 public function __construct( $languageCode = 'qqx' ) {
28 $this->languageCode
= $languageCode;
32 * Get a Message object.
33 * Parameters are the same as {@link wfMessage()}.
35 * @param string|string[]|MessageSpecifier $key Message key, or array of keys,
36 * or a MessageSpecifier.
37 * @param mixed $args,...
40 public function msg( $key ) {
41 $args = func_get_args();
43 /** @var Message $message */
44 $message = call_user_func_array( 'wfMessage', $args );
46 if ( $this->languageCode
!== null ) {
47 $message->inLanguage( $this->languageCode
);