Page MenuHomeWickedGov Phorge

MockLocalisationCacheTrait.php
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

MockLocalisationCacheTrait.php

<?php
namespace MediaWiki\Tests\Language;
use LCStoreDB;
use LocalisationCache;
use MediaWiki\Config\ServiceOptions;
use MediaWiki\Tests\Unit\DummyServicesTrait;
use Psr\Log\NullLogger;
/**
* Allows the construction of a mock {@link LocalisationCache} that has a limited pre-determined list of
* message keys.
*/
trait MockLocalisationCacheTrait {
use DummyServicesTrait;
/**
* @param array $hooks Hook overrides
* @param array $options Service options (see {@link LocalisationCache::CONSTRUCTOR_OPTIONS})
* @return LocalisationCache
*/
protected function getMockLocalisationCache( array $hooks = [], array $options = [] ): LocalisationCache {
$hookContainer = $this->createHookContainer( $hooks );
// in case any of the LanguageNameUtils hooks are being used
$langNameUtils = $this->getDummyLanguageNameUtils(
[ 'hookContainer' => $hookContainer ]
);
$options += [
'forceRecache' => false,
'manualRecache' => false,
'ExtensionMessagesFiles' => [],
'MessagesDirs' => [],
'TranslationAliasesDirs' => [],
];
$lc = $this->getMockBuilder( LocalisationCache::class )
->setConstructorArgs( [
new ServiceOptions( LocalisationCache::CONSTRUCTOR_OPTIONS, $options ),
new LCStoreDB( [] ),
new NullLogger,
[],
$langNameUtils,
$hookContainer
] )
->onlyMethods( [ 'getMessagesDirs' ] )
->getMock();
$lc->method( 'getMessagesDirs' )
->willReturn( [ MW_INSTALL_PATH . "/tests/phpunit/data/localisationcache" ] );
return $lc;
}
}

File Metadata

Mime Type
text/x-php
Expires
Tue, Aug 18, 18:47 (3 w, 14 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
f0/5a/2635f5646aed94c3bb427e481df6
Default Alt Text
MockLocalisationCacheTrait.php (1 KB)

Event Timeline