15 MessageCache::destroyInstance();
16 MessageCache::singleton()->enable();
33 $this->
makePage(
'FallbackLanguageTest-Full',
'ab' );
34 $this->
makePage(
'FallbackLanguageTest-Full',
'ru' );
35 $this->
makePage(
'FallbackLanguageTest-Full',
'de' );
38 $this->
makePage(
'FallbackLanguageTest-Partial',
'ru' );
39 $this->
makePage(
'FallbackLanguageTest-Partial',
'de' );
42 $this->
makePage(
'FallbackLanguageTest-ContLang',
'de' );
48 $this->
makePage(
'MessageCacheTest-FullKeyTest',
'ab' );
49 $this->
makePage(
'MessageCacheTest-FullKeyTest',
'ru' );
52 $this->
makePage(
'FallbackLanguageTest-NoDervContLang',
'de',
'de/none' );
66 if (
$lang !== MediaWikiServices::getInstance()->getContentLanguage()->getCode() ) {
67 $title =
"$title/$lang";
70 $title = Title::newFromText( $title, NS_MEDIAWIKI );
72 $contentHandler = ContentHandler::makeContent(
$content, $title );
73 $wikiPage->doEditContent( $contentHandler,
"$lang translation test case" );
82 $result = MessageCache::singleton()->get( $message,
true,
$lang );
83 $this->assertEquals( $expectedContent, $result,
"Message fallback failed." );
88 [
'FallbackLanguageTest-Full',
'ab',
'ab' ],
89 [
'FallbackLanguageTest-Partial',
'ab',
'ru' ],
90 [
'FallbackLanguageTest-ContLang',
'ab',
'de' ],
91 [
'FallbackLanguageTest-None',
'ab',
false ],
94 [
'sunday',
'ab',
'амҽыш' ],
97 [
'FallbackLanguageTest-NoDervContLang',
'de',
'de/none' ],
99 [
'FallbackLanguageTest-NoDervContLang',
'fit',
'de/none' ],
104 $messageCache = MessageCache::singleton();
106 $uckey = MediaWikiServices::getInstance()->getContentLanguage()->ucfirst( $message );
107 $oldText = $messageCache->get( $message );
110 $dbw->startAtomic( __METHOD__ );
111 $messageCache->replace( $uckey,
'Allez!' );
112 $this->assertEquals(
'Allez!',
113 $messageCache->getMsgFromNamespace( $uckey,
'de' ),
114 'Updates are reflected in-process immediately' );
115 $this->assertEquals(
'Allez!',
116 $messageCache->get( $message ),
117 'Updates are reflected in-process immediately' );
118 $this->
makePage(
'Go',
'de',
'Race!' );
119 $dbw->endAtomic( __METHOD__ );
121 $this->assertEquals( 0,
122 DeferredUpdates::pendingUpdatesCount(),
123 'Post-commit deferred update triggers a run of all updates' );
125 $this->assertEquals(
'Race!', $messageCache->get( $message ),
'Correct final contents' );
127 $this->
makePage(
'Go',
'de', $oldText );
128 $messageCache->replace( $uckey, $oldText );
129 $this->assertEquals( $oldText, $messageCache->get( $message ),
'Content restored' );
137 'wgMainWANCache' =>
'hash',
138 'wgWANObjectCaches' => $wgWANObjectCaches + [
140 'class' => WANObjectCache::class,
148 MessageCache::destroyInstance();
149 $messageCache = MessageCache::singleton();
150 $messageCache->enable();
153 $this->
makePage(
'Key1',
'de',
'Value1' );
154 $this->assertEquals( 0,
155 DeferredUpdates::pendingUpdatesCount(),
156 'Post-commit deferred update triggers a run of all updates' );
157 $this->assertEquals(
'Value1', $messageCache->get(
'Key1' ),
'Key1 was successfully edited' );
162 'page', [
'page_namespace' => NS_MEDIAWIKI,
'page_title' =>
'Key1' ], __METHOD__
166 $this->
makePage(
'Key2',
'de',
'Value2' );
167 $this->assertEquals( 0,
168 DeferredUpdates::pendingUpdatesCount(),
169 'Post-commit deferred update triggers a run of all updates' );
170 $this->assertEquals(
'Value2', $messageCache->get(
'Key2' ),
'Key2 was successfully edited' );
173 $this->assertEquals(
'Value1', $messageCache->get(
'Key1' ),
174 'Key1 wasn\'t reloaded by edit of Key2' );
181 $actual = MessageCache::normalizeKey( $key );
182 $this->assertEquals( $expected, $actual );
191 [
'Foo bar',
'foo_bar' ],
193 [
'Ćab_e 3',
'ćab_e_3' ],
207 $this->assertEquals( 0,
$dbr->trxLevel() );
212 $dbr->restoreFlags();
214 $this->assertEquals( 0,
$dbr->trxLevel(),
"No DB read queries" );
$wgWANObjectCaches
Advanced WAN object cache configuration.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
foreach(LanguageCode::getNonstandardLanguageCodeMapping() as $code=> $bcp47) $wgContLanguageCode
Database Cache MessageCache.
provideMessagesForFallback()
testMessageFallbacks( $message, $lang, $expectedContent)
Test message fallbacks, T3495.
testNormalizeKey( $key, $expected)
provideNormalizeKey
makePage( $title, $lang, $content=null)
Helper function for addDBData – adds a simple page to the database.
configureLanguages()
Helper function – setup site language for testing.
Class representing a MediaWiki article and history.
processing should stop and the error should be shown to the user * false
if(!isset( $args[0])) $lang