X-Git-Url: https://scripts.mit.edu/gitweb/autoinstallsdev/mediawiki.git/blobdiff_plain/19e297c21b10b1b8a3acad5e73fc71dcb35db44a..6932310fd58ebef145fa01eb76edf7150284d8ea:/tests/phpunit/languages/classes/LanguageHeTest.php diff --git a/tests/phpunit/languages/classes/LanguageHeTest.php b/tests/phpunit/languages/classes/LanguageHeTest.php new file mode 100644 index 00000000..c1b774af --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageHeTest.php @@ -0,0 +1,132 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider provideThreePluralForms + * @covers Language::convertPlural + */ + public function testThreePluralForms( $result, $value ) { + $forms = [ 'one', 'two', 'other' ]; + $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider provideFourPluralForms + * @covers Language::convertPlural + */ + public function testFourPluralForms( $result, $value ) { + $forms = [ 'one', 'two', 'many', 'other' ]; + $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider provideFourPluralForms + * @covers Language::convertPlural + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static function provideTwoPluralForms() { + return [ + [ 'other', 0 ], // Zero - plural + [ 'one', 1 ], // Singular + [ 'other', 2 ], // No third form provided, use it as plural + [ 'other', 3 ], // Plural - other + [ 'other', 10 ], // No fourth form provided, use it as plural + [ 'other', 20 ], // No fourth form provided, use it as plural + ]; + } + + public static function provideThreePluralForms() { + return [ + [ 'other', 0 ], // Zero - plural + [ 'one', 1 ], // Singular + [ 'two', 2 ], // Dual + [ 'other', 3 ], // Plural - other + [ 'other', 10 ], // No fourth form provided, use it as plural + [ 'other', 20 ], // No fourth form provided, use it as plural + ]; + } + + public static function provideFourPluralForms() { + return [ + [ 'other', 0 ], // Zero - plural + [ 'one', 1 ], // Singular + [ 'two', 2 ], // Dual + [ 'other', 3 ], // Plural - other + [ 'other', 10 ], // 10 is supposed to be plural (other), not "many" + [ 'many', 20 ], // Fourth form provided - rare, but supported by CLDR + ]; + } + + /** + * @dataProvider provideGrammar + * @covers Language::convertGrammar + */ + public function testGrammar( $result, $word, $case ) { + $this->assertEquals( $result, $this->getLang()->convertGrammar( $word, $case ) ); + } + + // The comments in the beginning of the line help avoid RTL problems + // with text editors. + public static function provideGrammar() { + return [ + [ + /* result */'וויקיפדיה', + /* word */'ויקיפדיה', + /* case */'תחילית', + ], + [ + /* result */'וולפגנג', + /* word */'וולפגנג', + /* case */'prefixed', + ], + [ + /* result */'קובץ', + /* word */'הקובץ', + /* case */'תחילית', + ], + [ + /* result */'־Wikipedia', + /* word */'Wikipedia', + /* case */'תחילית', + ], + [ + /* result */'־1995', + /* word */'1995', + /* case */'תחילית', + ], + ]; + } +}