wiki.techinc.nl/tests/phpunit/data/localisationcache/ExtensionMessagesFiles.php
Lucas Werkmeister fee22e61d8 LocalisationCache: Add tests for preload behavior
The new block in testRecacheExtensionMessagesFiles() covers the
underlying issue of T343343 and T343375; see change Icc3324aca7 for an
explanation of the issue.

In order for this test to not crash, we also need to adjust some of the
other tests and data. MessagesEn.php defines $preloadedMessages, and
LocalisationCache assumes (quite rightly so, really) that all of these
messages will be found in the configured MessagesDirs. But in the test,
we override MessagesDirs to point at the test’s JSON files, while still
using the original MessagesEn.php with its $preloadedMessages. Now that
we are triggering the preload mechanism (I think it wasn’t reached by
the tests previously?), it triggers a PHP deprecation (since PHP 8) on
the missing messages, which makes the test fail:

> explode(): Passing null to parameter #2 ($string) of type string is deprecated

I decided to fix this by adding fake entries for all $preloadedMessages
to the test en.json file. This makes the other tests that compare the
entire messages array fail, so instead only compare the three messages
those tests care about ("present-*"). I don’t like this very much, but I
dislike the other two approaches I can think of even more: check
defined( 'MW_PHPUNIT_TEST' ) in the original MessagesEn.php file, or add
a test-specific MessagesEn.php using the Language::getMessagesFileName
hook.

Bug: T342418
Bug: T343343
Bug: T343375
Change-Id: Iee11cb5c52cb9dd777b70a1daa06f41f2c3ca187
2023-08-08 13:09:34 +02:00

29 lines
736 B
PHP

<?php
/**
* This file is loaded in LocalisationCacheTest::testRecacheExtensionMessagesFiles().
*/
// $specialPageAliases can be set
$specialPageAliases['de'] = [
// new key not found in core message files
'LocalisationCacheTest' => [ 'LokalisierungsPufferTest' ],
// merged with fallback languages (below) and core message files
'Activeusers' => [ 'Aktive_Benutzer*innen' ],
];
$specialPageAliases['en'] = [
'Activeusers' => [ 'ActiveFolx' ],
];
// $namespaceNames can be set
$namespaceNames['en'] = [
98 => 'LocalisationCacheTest',
99 => 'LocalisationCacheTest_talk',
];
$namespaceNames['de'] = [
98 => 'LokalisierungsPufferTest',
99 => 'LokalisierungsPufferTest_Diskussion',
];
// $rtl cannot be set
$rtl['de'] = true;