blob: 05b3d037f2a1b6f9c0735a8b0bf878de6c7d8a36 (
plain) (
blame)
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
50
|
<?php
namespace MediaWiki\Tests\Language;
use MessageCache;
/**
* Trait for asserting that the localization component is getting notified
* about changes as expected.
*/
trait LocalizationUpdateSpyTrait {
/**
* Register expectations about updates that should get triggered.
* The parameters of this method represent known kinds of updates.
* If a parameter is added, tests calling this method should be forced
* to specify their expectations with respect to that kind of update.
* For this reason, this method should not be split, and all parameters
* should be required.
*/
private function expectLocalizationUpdate( int $messageOverrides ) {
// Make sure LanguageEventIngress is triggered and updates the message
$messageCache = $this->createNoOpMock(
MessageCache::class,
[
'updateMessageOverride',
'figureMessage',
'get',
'transform',
'getMsgFromNamespace',
]
);
// this is the relevant assertion:
$messageCache->expects( $this->exactly( $messageOverrides ) )
->method( 'updateMessageOverride' );
$messageCache->method( 'figureMessage' )
->willReturn( [ 'xxx', 'en' ] );
$messageCache->method( 'get' )
->willReturn( 'dummy test' );
$messageCache->method( 'getMsgFromNamespace' )
->willReturn( false );
$this->setService( 'MessageCache', $messageCache );
}
}
|