function LocaleLookupTest::testFixOldPluralStyleTranslations
Same name in other branches
- 9 core/modules/locale/tests/src/Unit/LocaleLookupTest.php \Drupal\Tests\locale\Unit\LocaleLookupTest::testFixOldPluralStyleTranslations()
- 8.9.x core/modules/locale/tests/src/Unit/LocaleLookupTest.php \Drupal\Tests\locale\Unit\LocaleLookupTest::testFixOldPluralStyleTranslations()
- 10 core/modules/locale/tests/src/Unit/LocaleLookupTest.php \Drupal\Tests\locale\Unit\LocaleLookupTest::testFixOldPluralStyleTranslations()
Tests locale lookups with old plural style of translations.
@covers ::resolveCacheMiss @dataProvider providerFixOldPluralTranslationProvider
Parameters
array $translations: The source with translations.
string $langcode: The language code of translation string.
string $string: The string for translation.
bool $is_fix: The flag about expected fix translation.
File
-
core/
modules/ locale/ tests/ src/ Unit/ LocaleLookupTest.php, line 294
Class
- LocaleLookupTest
- @coversDefaultClass \Drupal\locale\LocaleLookup @group locale
Namespace
Drupal\Tests\locale\UnitCode
public function testFixOldPluralStyleTranslations($translations, $langcode, $string, $is_fix) : void {
$this->storage
->expects($this->any())
->method('findTranslation')
->willReturnCallback(function ($argument) use ($translations) {
if (isset($translations[$argument['language']][$argument['source']])) {
return (object) [
'translation' => $translations[$argument['language']][$argument['source']],
];
}
return TRUE;
});
$this->languageManager
->expects($this->any())
->method('getFallbackCandidates')
->willReturnCallback(function (array $context = []) {
switch ($context['langcode']) {
case 'by':
return [
'ru',
];
}
});
$this->cache
->expects($this->once())
->method('get')
->with('locale:' . $langcode . '::anonymous', FALSE);
$locale_lookup = new LocaleLookup($langcode, '', $this->storage, $this->cache, $this->lock, $this->configFactory, $this->languageManager, $this->requestStack);
if ($is_fix) {
$this->assertStringNotContainsString('@count[2]', $locale_lookup->get($string));
}
else {
$this->assertStringContainsString('@count[2]', $locale_lookup->get($string));
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.