blob: 143a419f052d0f019bffca9787458bf5150edaaf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
<?php
/**
* A simple {@link MessageLocalizer} implementation for use in tests.
* By default, it sets the message language to 'qqx',
* to make the tests independent of the wiki configuration.
*
* @author Lucas Werkmeister
* @license GPL-2.0-or-later
*/
class MockMessageLocalizer implements MessageLocalizer {
/**
* @var string|null
*/
private $languageCode;
/**
* @param string|null $languageCode The language code to use for messages by default.
* You can specify null to use the user language,
* but this is not recommended as it may make your tests depend on the wiki configuration.
*/
public function __construct( $languageCode = 'qqx' ) {
$this->languageCode = $languageCode;
}
/**
* Get a Message object.
* Parameters are the same as {@link wfMessage()}.
*
* @param string|string[]|MessageSpecifier $key Message key, or array of keys,
* or a MessageSpecifier.
* @param mixed $args,...
* @return Message
*/
public function msg( $key ) {
$args = func_get_args();
/** @var Message $message */
$message = call_user_func_array( 'wfMessage', $args );
if ( $this->languageCode !== null ) {
$message->inLanguage( $this->languageCode );
}
return $message;
}
}
|