public function LocaleLocaleLookupTest::testFixOldPluralStyle in Drupal 8
Same name and namespace in other branches
- 9 core/modules/locale/tests/src/Functional/LocaleLocaleLookupTest.php \Drupal\Tests\locale\Functional\LocaleLocaleLookupTest::testFixOldPluralStyle()
Test old plural style @count[number] fix.
@dataProvider providerTestFixOldPluralStyle
File
- core/
modules/ locale/ tests/ src/ Functional/ LocaleLocaleLookupTest.php, line 69
Class
- LocaleLocaleLookupTest
- Tests LocaleLookup.
Namespace
Drupal\Tests\locale\FunctionalCode
public function testFixOldPluralStyle($translation_value, $expected) {
$string_storage = \Drupal::service('locale.storage');
$string = $string_storage
->findString([
'source' => 'Member for',
'context' => '',
]);
$lid = $string
->getId();
$string_storage
->createTranslation([
'lid' => $lid,
'language' => 'fr',
'translation' => $translation_value,
])
->save();
_locale_refresh_translations([
'fr',
], [
$lid,
]);
// Check that 'count[2]' was fixed for render value.
$this
->drupalGet('');
$this
->assertSession()
->pageTextContains($expected);
// Check that 'count[2]' was saved for source value.
$translation = $string_storage
->findTranslation([
'language' => 'fr',
'lid' => $lid,
])->translation;
$this
->assertSame($translation_value, $translation, 'Source value not changed');
$this
->assertStringContainsString('@count[2]', $translation, 'Source value contains @count[2]');
}