TranslatorTest
extends TestCase
in package
Test should cover all languages mentioned on http://translate.sourceforge.net/wiki/l10n/pluralforms and Plural forms mentioned on http://www.gnu.org/software/gettext/manual/gettext.html#Plural-forms.
See also https://developer.mozilla.org/en/Localization_and_Plurals which mentions 15 rules having a maximum of 6 forms. The mozilla code is also interesting to check for.
As mentioned by chx http://drupal.org/node/1273968 we can cover all by testing number from 0 to 199
The goal to cover all languages is to far fetched so this test case is smaller.
Tags
Table of Contents
- $defaultLocale : mixed
- failingLangcodes() : array<string|int, mixed>
- This array should be at least empty within the near future.
- getChooseTests() : mixed
- getInterval() : mixed
- getNonMatchingMessages() : mixed
- getTransChoiceTests() : mixed
- getTranslator() : TranslatorInterface
- getTransTests() : mixed
- successLangcodes() : array<string|int, mixed>
- This array should contain all currently known langcodes.
- testChoose() : mixed
- testFailedLangcodes() : mixed
- testGetLocaleReturnsDefaultLocaleIfNotSet() : mixed
- testGetSetLocale() : mixed
- testInterval() : mixed
- testLangcodes() : mixed
- testReturnMessageIfExactlyOneStandardRuleIsGiven() : mixed
- testThrowExceptionIfMatchingMessageCannotBeFound() : mixed
- testTrans() : mixed
- testTransChoiceWithDefaultLocale() : mixed
- testTransChoiceWithEnUsPosix() : mixed
- testTransChoiceWithExplicitLocale() : mixed
- generateTestData() : mixed
- setUp() : void
- tearDown() : void
- validateMatrix() : mixed
- We validate only on the plural coverage. Thus the real rules is not tested.
Properties
$defaultLocale
private
mixed
$defaultLocale
Methods
failingLangcodes()
This array should be at least empty within the near future.
public
static failingLangcodes() : array<string|int, mixed>
This both depends on a complete list trying to add above as understanding the plural rules of the current failing languages.
Return values
array<string|int, mixed> —with nplural together with langcodes
getChooseTests()
public
static getChooseTests() : mixed
Return values
mixed —getInterval()
public
static getInterval() : mixed
Return values
mixed —getNonMatchingMessages()
public
static getNonMatchingMessages() : mixed
Return values
mixed —getTransChoiceTests()
public
static getTransChoiceTests() : mixed
Return values
mixed —getTranslator()
public
getTranslator() : TranslatorInterface
Return values
TranslatorInterface —getTransTests()
public
static getTransTests() : mixed
Return values
mixed —successLangcodes()
This array should contain all currently known langcodes.
public
static successLangcodes() : array<string|int, mixed>
As it is impossible to have this ever complete we should try as hard as possible to have it almost complete.
Return values
array<string|int, mixed> —testChoose()
public
testChoose(mixed $expected, mixed $id, mixed $number[, mixed $locale = null ]) : mixed
Parameters
- $expected : mixed
- $id : mixed
- $number : mixed
- $locale : mixed = null
Tags
Return values
mixed —testFailedLangcodes()
public
testFailedLangcodes(mixed $nplural, mixed $langCodes) : mixed
Parameters
- $nplural : mixed
- $langCodes : mixed
Tags
Return values
mixed —testGetLocaleReturnsDefaultLocaleIfNotSet()
public
testGetLocaleReturnsDefaultLocaleIfNotSet() : mixed
Tags
Return values
mixed —testGetSetLocale()
public
testGetSetLocale() : mixed
Return values
mixed —testInterval()
public
testInterval(mixed $expected, mixed $number, mixed $interval) : mixed
Parameters
- $expected : mixed
- $number : mixed
- $interval : mixed
Tags
Return values
mixed —testLangcodes()
public
testLangcodes(mixed $nplural, mixed $langCodes) : mixed
Parameters
- $nplural : mixed
- $langCodes : mixed
Tags
Return values
mixed —testReturnMessageIfExactlyOneStandardRuleIsGiven()
public
testReturnMessageIfExactlyOneStandardRuleIsGiven() : mixed
Return values
mixed —testThrowExceptionIfMatchingMessageCannotBeFound()
public
testThrowExceptionIfMatchingMessageCannotBeFound(mixed $id, mixed $number) : mixed
Parameters
- $id : mixed
- $number : mixed
Tags
Return values
mixed —testTrans()
public
testTrans(mixed $expected, mixed $id, mixed $parameters) : mixed
Parameters
- $expected : mixed
- $id : mixed
- $parameters : mixed
Tags
Return values
mixed —testTransChoiceWithDefaultLocale()
public
testTransChoiceWithDefaultLocale(mixed $expected, mixed $id, mixed $number) : mixed
Parameters
- $expected : mixed
- $id : mixed
- $number : mixed
Tags
Return values
mixed —testTransChoiceWithEnUsPosix()
public
testTransChoiceWithEnUsPosix(mixed $expected, mixed $id, mixed $number) : mixed
Parameters
- $expected : mixed
- $id : mixed
- $number : mixed
Tags
Return values
mixed —testTransChoiceWithExplicitLocale()
public
testTransChoiceWithExplicitLocale(mixed $expected, mixed $id, mixed $number) : mixed
Parameters
- $expected : mixed
- $id : mixed
- $number : mixed
Tags
Return values
mixed —generateTestData()
protected
generateTestData(mixed $langCodes) : mixed
Parameters
- $langCodes : mixed
Return values
mixed —setUp()
protected
setUp() : void
Return values
void —tearDown()
protected
tearDown() : void
Return values
void —validateMatrix()
We validate only on the plural coverage. Thus the real rules is not tested.
protected
validateMatrix(string $nplural, array<string|int, mixed> $matrix[, bool $expectSuccess = true ]) : mixed
Parameters
- $nplural : string
-
Plural expected
- $matrix : array<string|int, mixed>
-
Containing langcodes and their plural index values
- $expectSuccess : bool = true