Merge pull request #13043 from appwrite/fix/locale-fallback-test

test(locale): stop relying on incomplete French catalog in FallbackTest
This commit is contained in:
Chirag Aggarwal authored and GitHub committed 2026-07-30 09:30:29 +05:30
commit e4fea16e17
1 file changed
+13 -7
+13 -7
View File
@@ -14,12 +14,18 @@ final class FallbackTest extends TestCase
$translationsDir = __DIR__ . '/../../../app/config/locale/translations';
Locale::$exceptions = false;
Locale::setLanguageFromJSON('en', $translationsDir . '/en.json');
Locale::setLanguageFromJSON('fr', $translationsDir . '/fr.json');
// Synthetic incomplete catalog: keep one real key, omit email preview so
// the test does not depend on which shipped locales are still partial
// (e.g. fr.json was completed in #12449).
Locale::setLanguageFromArray('xx', [
'emails.verification.subject' => 'Account verification (xx)',
]);
}
public function testIncompleteLocaleFallsBackToEnglishForMissingEmailKeys(): void
{
$locale = new Locale('fr');
$locale = new Locale('xx');
$locale->setFallback('en');
$preview = $locale->getText('emails.verification.preview');
@@ -29,15 +35,15 @@ final class FallbackTest extends TestCase
'Verify your email to activate your {{project}} account.',
$preview
);
// Keys present in fr stay French.
$this->assertSame('Vérification du compte', $locale->getText('emails.verification.subject'));
// Keys present in the incomplete locale stay local.
$this->assertSame('Account verification (xx)', $locale->getText('emails.verification.subject'));
}
public function testFallbackMatchingIncompleteLocaleLeaksRawKeys(): void
{
$locale = new Locale('fr');
// Mirrors the previous bug: fallback = _APP_LOCALE when that env is fr.
$locale->setFallback('fr');
$locale = new Locale('xx');
// Mirrors the previous bug: fallback = request locale when that catalog is incomplete.
$locale->setFallback('xx');
$this->assertSame(
'{{emails.verification.preview}}',