$this->
drupalGet('numeric-test'
);
foreach ($numbers as $i =>
$number) { $this->
assertSession()->
responseContains('<span class="field-content">' .
$number .
($number == 1 ? ' time' : ' times'
) . '</span>'
);
} // Add Slovenian and set its plural formula to test multiple plural forms.
$edit =
['predefined_langcode' => 'sl'
];
$this->
drupalGet('admin/config/regional/language/add'
);
$this->
submitForm($edit, 'Add language'
);
$formula = 'nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);';
$header =
new PoHeader();
[$nplurals,
$formula] =
$header->
parsePluralForms($formula);
\Drupal::
service('locale.plural.formula'
)->
setPluralFormula('sl',
$nplurals,
$formula);
// Change the view to Slovenian.
$config =
$this->
config('views.view.numeric_test'
);
$config->
set('langcode', 'sl'
)->
save();
// Assert that the user interface has controls with more inputs now.
$this->
drupalGet('admin/structure/views/nojs/handler/numeric_test/page_1/field/count'
);
$this->
assertSession()->
fieldValueEquals('options[format_plural_values][0]', '1 time'
);
$this->
assertSession()->
fieldValueEquals('options[format_plural_values][1]', '@count times'
);
$this->
assertSession()->
fieldValueEquals('options[format_plural_values][2]', ''
);