2012-01-31 13:49:36 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* @author Amir E. Aharoni
|
|
|
|
|
* @copyright Copyright © 2012, Amir E. Aharoni
|
|
|
|
|
* @file
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/** Tests for MediaWiki languages/classes/LanguageHe.php */
|
2012-10-23 20:53:17 +00:00
|
|
|
class LanguageHeTest extends LanguageClassesTestCase {
|
2013-03-21 09:37:25 +00:00
|
|
|
/*
|
|
|
|
|
The most common usage for the plural forms is two forms,
|
|
|
|
|
for singular and plural. In this case, the second form
|
|
|
|
|
is technically dual, but in practice it's used as plural.
|
|
|
|
|
In some cases, usually with expressions of time, three forms
|
|
|
|
|
are needed - singular, dual and plural.
|
|
|
|
|
CLDR also specifies a fourth form for multiples of 10,
|
|
|
|
|
which is very rare. It also has a mistake, because
|
|
|
|
|
the number 10 itself is supposed to be just plural,
|
|
|
|
|
so currently it's overridden in MediaWiki.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/** @dataProvider provideTwoPluralForms */
|
|
|
|
|
function testTwoPluralForms( $result, $value ) {
|
|
|
|
|
$forms = array( 'one', 'other' );
|
|
|
|
|
$this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** @dataProvider provideThreePluralForms */
|
|
|
|
|
function testThreePluralForms( $result, $value ) {
|
2012-06-18 08:28:44 +00:00
|
|
|
$forms = array( 'one', 'two', 'other' );
|
2012-10-23 20:53:17 +00:00
|
|
|
$this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
|
2012-01-31 14:42:38 +00:00
|
|
|
}
|
|
|
|
|
|
2013-03-21 09:37:25 +00:00
|
|
|
/** @dataProvider provideFourPluralForms */
|
|
|
|
|
function testFourPluralForms( $result, $value ) {
|
|
|
|
|
$forms = array( 'one', 'two', 'many', 'other' );
|
|
|
|
|
$this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** @dataProvider provideFourPluralForms */
|
2013-01-25 01:10:37 +00:00
|
|
|
function testGetPluralRuleType( $result, $value ) {
|
|
|
|
|
$this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) );
|
2012-01-31 13:49:36 +00:00
|
|
|
}
|
|
|
|
|
|
2013-03-21 09:37:25 +00:00
|
|
|
public static function provideTwoPluralForms() {
|
2013-03-25 23:27:14 +00:00
|
|
|
return array(
|
2013-03-21 09:37:25 +00:00
|
|
|
array( 'other', 0 ), // Zero - plural
|
|
|
|
|
array( 'one', 1 ), // Singular
|
|
|
|
|
array( 'other', 2 ), // No third form provided, use it as plural
|
|
|
|
|
array( 'other', 3 ), // Plural - other
|
|
|
|
|
array( 'other', 10 ), // No fourth form provided, use it as plural
|
|
|
|
|
array( 'other', 20 ), // No fourth form provided, use it as plural
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function provideThreePluralForms() {
|
2013-03-25 23:27:14 +00:00
|
|
|
return array(
|
2013-03-21 09:37:25 +00:00
|
|
|
array( 'other', 0 ), // Zero - plural
|
|
|
|
|
array( 'one', 1 ), // Singular
|
|
|
|
|
array( 'two', 2 ), // Dual
|
|
|
|
|
array( 'other', 3 ), // Plural - other
|
|
|
|
|
array( 'other', 10 ), // No fourth form provided, use it as plural
|
|
|
|
|
array( 'other', 20 ), // No fourth form provided, use it as plural
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function provideFourPluralForms() {
|
2013-03-25 23:27:14 +00:00
|
|
|
return array(
|
2013-03-21 09:37:25 +00:00
|
|
|
array( 'other', 0 ), // Zero - plural
|
|
|
|
|
array( 'one', 1 ), // Singular
|
|
|
|
|
array( 'two', 2 ), // Dual
|
|
|
|
|
array( 'other', 3 ), // Plural - other
|
|
|
|
|
array( 'other', 10 ), // 10 is supposed to be plural (other), not "many"
|
|
|
|
|
array( 'many', 20 ), // Fourth form provided - rare, but supported by CLDR
|
2012-01-31 13:49:36 +00:00
|
|
|
);
|
|
|
|
|
}
|
2012-11-10 09:45:27 +00:00
|
|
|
|
2013-01-25 01:10:37 +00:00
|
|
|
/** @dataProvider provideGrammar */
|
2012-11-10 09:45:27 +00:00
|
|
|
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.
|
2013-03-22 02:12:37 +00:00
|
|
|
public static function provideGrammar() {
|
2013-03-25 23:27:14 +00:00
|
|
|
return array(
|
2012-11-10 09:45:27 +00:00
|
|
|
array(
|
2013-03-25 23:27:14 +00:00
|
|
|
/* result */'וויקיפדיה',
|
|
|
|
|
/* word */'ויקיפדיה',
|
|
|
|
|
/* case */'תחילית',
|
2012-11-10 09:45:27 +00:00
|
|
|
),
|
|
|
|
|
array(
|
2013-03-25 23:27:14 +00:00
|
|
|
/* result */'וולפגנג',
|
|
|
|
|
/* word */'וולפגנג',
|
|
|
|
|
/* case */'prefixed',
|
2012-11-10 09:45:27 +00:00
|
|
|
),
|
|
|
|
|
array(
|
2013-03-25 23:27:14 +00:00
|
|
|
/* result */'קובץ',
|
|
|
|
|
/* word */'הקובץ',
|
|
|
|
|
/* case */'תחילית',
|
2012-11-10 09:45:27 +00:00
|
|
|
),
|
|
|
|
|
array(
|
2013-03-25 23:27:14 +00:00
|
|
|
/* result */'־Wikipedia',
|
|
|
|
|
/* word */'Wikipedia',
|
|
|
|
|
/* case */'תחילית',
|
2012-11-10 09:45:27 +00:00
|
|
|
),
|
|
|
|
|
array(
|
2013-03-25 23:27:14 +00:00
|
|
|
/* result */'־1995',
|
|
|
|
|
/* word */'1995',
|
|
|
|
|
/* case */'תחילית',
|
2012-11-10 09:45:27 +00:00
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
2012-01-31 13:49:36 +00:00
|
|
|
}
|