| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Tests\Language; |
| 4 |
|
| 5 |
use LCStoreDB; |
| 6 |
use LocalisationCache; |
| 7 |
use MediaWiki\Config\ServiceOptions; |
| 8 |
use MediaWiki\Tests\Unit\DummyServicesTrait; |
| 9 |
use Psr\Log\NullLogger; |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
trait MockLocalisationCacheTrait { |
| 16 |
use DummyServicesTrait; |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
protected function getMockLocalisationCache( array $hooks = [], array $options = [] ): LocalisationCache { |
| 24 |
$hookContainer = $this->createHookContainer( $hooks ); |
| 25 |
|
| 26 |
|
| 27 |
$langNameUtils = $this->getDummyLanguageNameUtils( |
| 28 |
[ 'hookContainer' => $hookContainer ] |
| 29 |
); |
| 30 |
|
| 31 |
$options += [ |
| 32 |
'forceRecache' => false, |
| 33 |
'manualRecache' => false, |
| 34 |
'ExtensionMessagesFiles' => [], |
| 35 |
'MessagesDirs' => [], |
| 36 |
'TranslationAliasesDirs' => [], |
| 37 |
]; |
| 38 |
|
| 39 |
$lc = $this->getMockBuilder( LocalisationCache::class ) |
| 40 |
->setConstructorArgs( [ |
| 41 |
new ServiceOptions( LocalisationCache::CONSTRUCTOR_OPTIONS, $options ), |
| 42 |
new LCStoreDB( [] ), |
| 43 |
new NullLogger, |
| 44 |
[], |
| 45 |
$langNameUtils, |
| 46 |
$hookContainer |
| 47 |
] ) |
| 48 |
->onlyMethods( [ 'getMessagesDirs' ] ) |
| 49 |
->getMock(); |
| 50 |
$lc->method( 'getMessagesDirs' ) |
| 51 |
->willReturn( [ MW_INSTALL_PATH . "/tests/phpunit/data/localisationcache" ] ); |
| 52 |
|
| 53 |
return $lc; |
| 54 |
} |
| 55 |
} |