From d9022f63880ce039446fba8364f68e656b7bf4cb Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 3 May 2012 13:01:35 +0200 Subject: Update to MediaWiki 1.19.0 --- tests/phpunit/languages/LanguageAmTest.php | 33 ++ tests/phpunit/languages/LanguageArTest.php | 78 +++ tests/phpunit/languages/LanguageBeTest.php | 40 ++ tests/phpunit/languages/LanguageBe_taraskTest.php | 35 ++ tests/phpunit/languages/LanguageBhTest.php | 34 ++ tests/phpunit/languages/LanguageBsTest.php | 41 ++ tests/phpunit/languages/LanguageCsTest.php | 40 ++ tests/phpunit/languages/LanguageCuTest.php | 41 ++ tests/phpunit/languages/LanguageCyTest.php | 42 ++ tests/phpunit/languages/LanguageDsbTest.php | 40 ++ tests/phpunit/languages/LanguageFrTest.php | 34 ++ tests/phpunit/languages/LanguageGaTest.php | 34 ++ tests/phpunit/languages/LanguageGdTest.php | 38 ++ tests/phpunit/languages/LanguageGvTest.php | 39 ++ tests/phpunit/languages/LanguageHeTest.php | 48 ++ tests/phpunit/languages/LanguageHiTest.php | 34 ++ tests/phpunit/languages/LanguageHrTest.php | 41 ++ tests/phpunit/languages/LanguageHsbTest.php | 40 ++ tests/phpunit/languages/LanguageHyTest.php | 34 ++ tests/phpunit/languages/LanguageKshTest.php | 34 ++ tests/phpunit/languages/LanguageLnTest.php | 34 ++ tests/phpunit/languages/LanguageLtTest.php | 53 ++ tests/phpunit/languages/LanguageLvTest.php | 39 ++ tests/phpunit/languages/LanguageMgTest.php | 35 ++ tests/phpunit/languages/LanguageMkTest.php | 41 ++ tests/phpunit/languages/LanguageMlTest.php | 43 ++ tests/phpunit/languages/LanguageMoTest.php | 43 ++ tests/phpunit/languages/LanguageMtTest.php | 72 +++ tests/phpunit/languages/LanguageNlTest.php | 28 + tests/phpunit/languages/LanguageNsoTest.php | 32 ++ tests/phpunit/languages/LanguagePlTest.php | 72 +++ tests/phpunit/languages/LanguageRoTest.php | 43 ++ tests/phpunit/languages/LanguageRuTest.php | 54 ++ tests/phpunit/languages/LanguageSeTest.php | 48 ++ tests/phpunit/languages/LanguageSgsTest.php | 66 +++ tests/phpunit/languages/LanguageShTest.php | 32 ++ tests/phpunit/languages/LanguageSkTest.php | 40 ++ tests/phpunit/languages/LanguageSlTest.php | 42 ++ tests/phpunit/languages/LanguageSmaTest.php | 48 ++ tests/phpunit/languages/LanguageSrTest.php | 199 ++++++++ tests/phpunit/languages/LanguageTest.php | 591 ++++++++++++++++++---- tests/phpunit/languages/LanguageTiTest.php | 32 ++ tests/phpunit/languages/LanguageTlTest.php | 32 ++ tests/phpunit/languages/LanguageTrTest.php | 9 +- tests/phpunit/languages/LanguageUkTest.php | 54 ++ tests/phpunit/languages/LanguageWaTest.php | 32 ++ 46 files changed, 2521 insertions(+), 93 deletions(-) create mode 100644 tests/phpunit/languages/LanguageAmTest.php create mode 100644 tests/phpunit/languages/LanguageArTest.php create mode 100644 tests/phpunit/languages/LanguageBeTest.php create mode 100644 tests/phpunit/languages/LanguageBhTest.php create mode 100644 tests/phpunit/languages/LanguageBsTest.php create mode 100644 tests/phpunit/languages/LanguageCsTest.php create mode 100644 tests/phpunit/languages/LanguageCuTest.php create mode 100644 tests/phpunit/languages/LanguageCyTest.php create mode 100644 tests/phpunit/languages/LanguageDsbTest.php create mode 100644 tests/phpunit/languages/LanguageFrTest.php create mode 100644 tests/phpunit/languages/LanguageGaTest.php create mode 100644 tests/phpunit/languages/LanguageGdTest.php create mode 100644 tests/phpunit/languages/LanguageGvTest.php create mode 100644 tests/phpunit/languages/LanguageHeTest.php create mode 100644 tests/phpunit/languages/LanguageHiTest.php create mode 100644 tests/phpunit/languages/LanguageHrTest.php create mode 100644 tests/phpunit/languages/LanguageHsbTest.php create mode 100644 tests/phpunit/languages/LanguageHyTest.php create mode 100644 tests/phpunit/languages/LanguageKshTest.php create mode 100644 tests/phpunit/languages/LanguageLnTest.php create mode 100644 tests/phpunit/languages/LanguageLtTest.php create mode 100644 tests/phpunit/languages/LanguageLvTest.php create mode 100644 tests/phpunit/languages/LanguageMgTest.php create mode 100644 tests/phpunit/languages/LanguageMkTest.php create mode 100644 tests/phpunit/languages/LanguageMlTest.php create mode 100644 tests/phpunit/languages/LanguageMoTest.php create mode 100644 tests/phpunit/languages/LanguageMtTest.php create mode 100644 tests/phpunit/languages/LanguageNlTest.php create mode 100644 tests/phpunit/languages/LanguageNsoTest.php create mode 100644 tests/phpunit/languages/LanguagePlTest.php create mode 100644 tests/phpunit/languages/LanguageRoTest.php create mode 100644 tests/phpunit/languages/LanguageRuTest.php create mode 100644 tests/phpunit/languages/LanguageSeTest.php create mode 100644 tests/phpunit/languages/LanguageSgsTest.php create mode 100644 tests/phpunit/languages/LanguageShTest.php create mode 100644 tests/phpunit/languages/LanguageSkTest.php create mode 100644 tests/phpunit/languages/LanguageSlTest.php create mode 100644 tests/phpunit/languages/LanguageSmaTest.php create mode 100644 tests/phpunit/languages/LanguageSrTest.php create mode 100644 tests/phpunit/languages/LanguageTiTest.php create mode 100644 tests/phpunit/languages/LanguageTlTest.php create mode 100644 tests/phpunit/languages/LanguageUkTest.php create mode 100644 tests/phpunit/languages/LanguageWaTest.php (limited to 'tests/phpunit/languages') diff --git a/tests/phpunit/languages/LanguageAmTest.php b/tests/phpunit/languages/LanguageAmTest.php new file mode 100644 index 00000000..3a648ded --- /dev/null +++ b/tests/phpunit/languages/LanguageAmTest.php @@ -0,0 +1,33 @@ +lang = Language::factory( 'Am' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providePlural */ + function testPlural( $result, $value ) { + $forms = array( 'one', 'other' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providePlural() { + return array ( + array( 'one', 0 ), + array( 'one', 1 ), + array( 'other', 2 ), + array( 'other', 200 ), + ); + } +} diff --git a/tests/phpunit/languages/LanguageArTest.php b/tests/phpunit/languages/LanguageArTest.php new file mode 100644 index 00000000..b23e0534 --- /dev/null +++ b/tests/phpunit/languages/LanguageArTest.php @@ -0,0 +1,78 @@ +lang = Language::factory( 'Ar' ); + } + function tearDown() { + unset( $this->lang ); + } + + function testFormatNum() { + $this->assertEquals( '١٬٢٣٤٬٥٦٧', $this->lang->formatNum( '1234567' ) ); + $this->assertEquals( '-١٢٫٨٩', $this->lang->formatNum( -12.89 ) ); + } + + /** + * Mostly to test the raw ascii feature. + * @dataProvider providerSprintfDate + */ + function testSprintfDate( $format, $date, $expected ) { + $this->assertEquals( $expected, $this->lang->sprintfDate( $format, $date ) ); + } + + function providerSprintfDate() { + return array( + array( + 'xg "vs" g', + '20120102030410', + 'يناير vs ٣' + ), + array( + 'xmY', + '20120102030410', + '١٤٣٣' + ), + array( + 'xnxmY', + '20120102030410', + '1433' + ), + array( + 'xN xmj xmn xN xmY', + '20120102030410', + ' 7 2 ١٤٣٣' + ), + ); + } + /** @dataProvider providePlural */ + function testPlural( $result, $value ) { + $forms = array( 'zero', 'one', 'two', 'few', 'many', 'other' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + function providePlural() { + return array ( + array( 'zero', 0 ), + array( 'one', 1 ), + array( 'two', 2 ), + array( 'few', 3 ), + array( 'few', 9 ), + array( 'few', 110 ), + array( 'many', 11 ), + array( 'many', 15 ), + array( 'many', 99 ), + array( 'many', 9999 ), + array( 'other', 100 ), + array( 'other', 102 ), + array( 'other', 1000 ), + array( 'other', 1.7 ), + ); + } +} diff --git a/tests/phpunit/languages/LanguageBeTest.php b/tests/phpunit/languages/LanguageBeTest.php new file mode 100644 index 00000000..735ccc63 --- /dev/null +++ b/tests/phpunit/languages/LanguageBeTest.php @@ -0,0 +1,40 @@ +lang = Language::factory( 'Be' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providePlural */ + function testPlural( $result, $value ) { + $forms = array( 'one', 'few', 'many', 'other' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providePlural() { + return array ( + array( 'one', 1 ), + array( 'many', 11 ), + array( 'one', 91 ), + array( 'one', 121 ), + array( 'few', 2 ), + array( 'few', 3 ), + array( 'few', 4 ), + array( 'few', 334 ), + array( 'many', 5 ), + array( 'many', 15 ), + array( 'many', 120 ), + ); + } +} diff --git a/tests/phpunit/languages/LanguageBe_taraskTest.php b/tests/phpunit/languages/LanguageBe_taraskTest.php index e7fdb7ca..765cdb8f 100644 --- a/tests/phpunit/languages/LanguageBe_taraskTest.php +++ b/tests/phpunit/languages/LanguageBe_taraskTest.php @@ -27,4 +27,39 @@ class LanguageBeTaraskTest extends MediaWikiTestCase { function testDoesNotCommafyFourDigitsNumber() { $this->assertEquals( '1234', $this->lang->commafy( '1234' ) ); } + /** @dataProvider providePluralFourForms */ + function testPluralFourForms( $result, $value ) { + $forms = array( 'one', 'few', 'many', 'other' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providePluralFourForms() { + return array ( + array( 'one', 1 ), + array( 'many', 11 ), + array( 'one', 91 ), + array( 'one', 121 ), + array( 'few', 2 ), + array( 'few', 3 ), + array( 'few', 4 ), + array( 'few', 334 ), + array( 'many', 5 ), + array( 'many', 15 ), + array( 'many', 120 ), + ); + } + /** @dataProvider providePluralTwoForms */ + function testPluralTwoForms( $result, $value ) { + $forms = array( 'one', 'several' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + function providePluralTwoForms() { + return array ( + array( 'one', 1 ), + array( 'several', 11 ), + array( 'several', 91 ), + array( 'several', 121 ), + ); + } + } diff --git a/tests/phpunit/languages/LanguageBhTest.php b/tests/phpunit/languages/LanguageBhTest.php new file mode 100644 index 00000000..e1e2a13e --- /dev/null +++ b/tests/phpunit/languages/LanguageBhTest.php @@ -0,0 +1,34 @@ +lang = Language::factory( 'Bh' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providePlural */ + function testPlural( $result, $value ) { + $forms = array( 'one', 'other' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providePlural() { + return array ( + array( 'one', 0 ), + array( 'one', 1 ), + array( 'other', 2 ), + array( 'other', 200 ), + ); + } + +} diff --git a/tests/phpunit/languages/LanguageBsTest.php b/tests/phpunit/languages/LanguageBsTest.php new file mode 100644 index 00000000..b6631c03 --- /dev/null +++ b/tests/phpunit/languages/LanguageBsTest.php @@ -0,0 +1,41 @@ +lang = Language::factory( 'Bs' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providePlural */ + function testPlural( $result, $value ) { + $forms = array( 'one', 'few', 'many', 'other' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providePlural() { + return array ( + array( 'many', 0 ), + array( 'one', 1 ), + array( 'few', 2 ), + array( 'few', 4 ), + array( 'many', 5 ), + array( 'many', 11 ), + array( 'many', 20 ), + array( 'one', 21 ), + array( 'few', 24 ), + array( 'many', 25 ), + array( 'many', 200 ), + ); + } + +} diff --git a/tests/phpunit/languages/LanguageCsTest.php b/tests/phpunit/languages/LanguageCsTest.php new file mode 100644 index 00000000..dda29f9a --- /dev/null +++ b/tests/phpunit/languages/LanguageCsTest.php @@ -0,0 +1,40 @@ +lang = Language::factory( 'cs' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providerPlural */ + function testPlural( $result, $value ) { + $forms = array( 'one', 'few', 'other' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providerPlural() { + return array ( + array( 'other', 0 ), + array( 'one', 1 ), + array( 'few', 2 ), + array( 'few', 3 ), + array( 'few', 4 ), + array( 'other', 5 ), + array( 'other', 11 ), + array( 'other', 20 ), + array( 'other', 25 ), + array( 'other', 200 ), + ); + } + +} diff --git a/tests/phpunit/languages/LanguageCuTest.php b/tests/phpunit/languages/LanguageCuTest.php new file mode 100644 index 00000000..f8186d7b --- /dev/null +++ b/tests/phpunit/languages/LanguageCuTest.php @@ -0,0 +1,41 @@ +lang = Language::factory( 'cu' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providerPlural */ + function testPlural( $result, $value ) { + $forms = array( 'one', 'few', 'many', 'other' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providerPlural() { + return array ( + array( 'other', 0 ), + array( 'one', 1 ), + array( 'few', 2 ), + array( 'many', 3 ), + array( 'many', 4 ), + array( 'other', 5 ), + array( 'one', 11 ), + array( 'other', 20 ), + array( 'few', 22 ), + array( 'many', 223 ), + array( 'other', 200 ), + ); + } + +} diff --git a/tests/phpunit/languages/LanguageCyTest.php b/tests/phpunit/languages/LanguageCyTest.php new file mode 100644 index 00000000..e9f9e410 --- /dev/null +++ b/tests/phpunit/languages/LanguageCyTest.php @@ -0,0 +1,42 @@ +lang = Language::factory( 'cy' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providerPlural */ + function testPlural( $result, $value ) { + $forms = array( 'zero', 'one', 'two', 'few', 'many', 'other' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providerPlural() { + return array ( + array( 'zero', 0 ), + array( 'one', 1 ), + array( 'two', 2 ), + array( 'few', 3 ), + array( 'many', 6 ), + array( 'other', 4 ), + array( 'other', 5 ), + array( 'other', 11 ), + array( 'other', 20 ), + array( 'other', 22 ), + array( 'other', 223 ), + array( 'other', 200.00 ), + ); + } + +} diff --git a/tests/phpunit/languages/LanguageDsbTest.php b/tests/phpunit/languages/LanguageDsbTest.php new file mode 100644 index 00000000..ab7f9313 --- /dev/null +++ b/tests/phpunit/languages/LanguageDsbTest.php @@ -0,0 +1,40 @@ +lang = Language::factory( 'dsb' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providePlural */ + function testPlural( $result, $value ) { + $forms = array( 'one', 'two', 'few', 'other' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providePlural() { + return array ( + array( 'other', 0 ), + array( 'one', 1 ), + array( 'one', 101 ), + array( 'one', 90001 ), + array( 'two', 2 ), + array( 'few', 3 ), + array( 'few', 203 ), + array( 'few', 4 ), + array( 'other', 99 ), + array( 'other', 555 ), + ); + } + +} diff --git a/tests/phpunit/languages/LanguageFrTest.php b/tests/phpunit/languages/LanguageFrTest.php new file mode 100644 index 00000000..8538744e --- /dev/null +++ b/tests/phpunit/languages/LanguageFrTest.php @@ -0,0 +1,34 @@ +lang = Language::factory( 'fr' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providePlural */ + function testPlural( $result, $value ) { + $forms = array( 'one', 'other' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providePlural() { + return array ( + array( 'one', 0 ), + array( 'one', 1 ), + array( 'other', 2 ), + array( 'other', 200 ), + ); + } + +} diff --git a/tests/phpunit/languages/LanguageGaTest.php b/tests/phpunit/languages/LanguageGaTest.php new file mode 100644 index 00000000..fbd9f11d --- /dev/null +++ b/tests/phpunit/languages/LanguageGaTest.php @@ -0,0 +1,34 @@ +lang = Language::factory( 'ga' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providerPlural */ + function testPlural( $result, $value ) { + $forms = array( 'one', 'two', 'other' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providerPlural() { + return array ( + array( 'other', 0 ), + array( 'one', 1 ), + array( 'two', 2 ), + array( 'other', 200 ), + ); + } + +} diff --git a/tests/phpunit/languages/LanguageGdTest.php b/tests/phpunit/languages/LanguageGdTest.php new file mode 100644 index 00000000..24574bda --- /dev/null +++ b/tests/phpunit/languages/LanguageGdTest.php @@ -0,0 +1,38 @@ +lang = Language::factory( 'gd' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providerPlural */ + function testPlural( $result, $value ) { + // The CLDR ticket for this plural forms is not same as mw plural forms. See http://unicode.org/cldr/trac/ticket/2883 + $forms = array( 'Form 1', 'Form 2', 'Form 3', 'Form 4', 'Form 5', 'Form 6' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + function providerPlural() { + return array ( + array( 'Form 6', 0 ), + array( 'Form 1', 1 ), + array( 'Form 2', 2 ), + array( 'Form 3', 11 ), + array( 'Form 4', 12 ), + array( 'Form 5', 3 ), + array( 'Form 5', 19 ), + array( 'Form 6', 200 ), + ); + } + +} diff --git a/tests/phpunit/languages/LanguageGvTest.php b/tests/phpunit/languages/LanguageGvTest.php new file mode 100644 index 00000000..3d298b9b --- /dev/null +++ b/tests/phpunit/languages/LanguageGvTest.php @@ -0,0 +1,39 @@ +lang = Language::factory( 'gv' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providerPlural */ + function testPlural( $result, $value ) { + // This is not compatible with CLDR plural rules http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#gv + $forms = array( 'Form 1', 'Form 2', 'Form 3', 'Form 4' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + function providerPlural() { + return array ( + array( 'Form 4', 0 ), + array( 'Form 2', 1 ), + array( 'Form 3', 2 ), + array( 'Form 4', 3 ), + array( 'Form 1', 20 ), + array( 'Form 2', 21 ), + array( 'Form 3', 22 ), + array( 'Form 4', 23 ), + array( 'Form 4', 50 ), + ); + } + +} diff --git a/tests/phpunit/languages/LanguageHeTest.php b/tests/phpunit/languages/LanguageHeTest.php new file mode 100644 index 00000000..9ac0f952 --- /dev/null +++ b/tests/phpunit/languages/LanguageHeTest.php @@ -0,0 +1,48 @@ +lang = Language::factory( 'he' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providerPluralDual */ + function testPluralDual( $result, $value ) { + $forms = array( 'one', 'many', 'two' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providerPluralDual() { + return array ( + array( 'many', 0 ), // Zero -> plural + array( 'one', 1 ), // Singular + array( 'two', 2 ), // Dual + array( 'many', 3 ), // Plural + ); + } + + /** @dataProvider providerPlural */ + function testPlural( $result, $value ) { + $forms = array( 'one', 'many' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providerPlural() { + return array ( + array( 'many', 0 ), // Zero -> plural + array( 'one', 1 ), // Singular + array( 'many', 2 ), // Plural, no dual provided + array( 'many', 3 ), // Plural + ); + } +} diff --git a/tests/phpunit/languages/LanguageHiTest.php b/tests/phpunit/languages/LanguageHiTest.php new file mode 100644 index 00000000..ead9e020 --- /dev/null +++ b/tests/phpunit/languages/LanguageHiTest.php @@ -0,0 +1,34 @@ +lang = Language::factory( 'Hi' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providePlural */ + function testPlural( $result, $value ) { + $forms = array( 'one', 'other' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providePlural() { + return array ( + array( 'one', 0 ), + array( 'one', 1 ), + array( 'other', 2 ), + array( 'other', 200 ), + ); + } + +} diff --git a/tests/phpunit/languages/LanguageHrTest.php b/tests/phpunit/languages/LanguageHrTest.php new file mode 100644 index 00000000..4f1c66bf --- /dev/null +++ b/tests/phpunit/languages/LanguageHrTest.php @@ -0,0 +1,41 @@ +lang = Language::factory( 'hr' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providerPlural */ + function testPlural( $result, $value ) { + $forms = array( 'one', 'few', 'many', 'other' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providerPlural() { + return array ( + array( 'many', 0 ), + array( 'one', 1 ), + array( 'few', 2 ), + array( 'few', 4 ), + array( 'many', 5 ), + array( 'many', 11 ), + array( 'many', 20 ), + array( 'one', 21 ), + array( 'few', 24 ), + array( 'many', 25 ), + array( 'many', 200 ), + ); + } + +} diff --git a/tests/phpunit/languages/LanguageHsbTest.php b/tests/phpunit/languages/LanguageHsbTest.php new file mode 100644 index 00000000..803c7721 --- /dev/null +++ b/tests/phpunit/languages/LanguageHsbTest.php @@ -0,0 +1,40 @@ +lang = Language::factory( 'hsb' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providePlural */ + function testPlural( $result, $value ) { + $forms = array( 'one', 'two', 'few', 'other' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providePlural() { + return array ( + array( 'other', 0 ), + array( 'one', 1 ), + array( 'one', 101 ), + array( 'one', 90001 ), + array( 'two', 2 ), + array( 'few', 3 ), + array( 'few', 203 ), + array( 'few', 4 ), + array( 'other', 99 ), + array( 'other', 555 ), + ); + } + +} diff --git a/tests/phpunit/languages/LanguageHyTest.php b/tests/phpunit/languages/LanguageHyTest.php new file mode 100644 index 00000000..7990bdfc --- /dev/null +++ b/tests/phpunit/languages/LanguageHyTest.php @@ -0,0 +1,34 @@ +lang = Language::factory( 'hy' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providerPlural */ + function testPlural( $result, $value ) { + $forms = array( 'one', 'other' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providerPlural() { + return array ( + array( 'one', 0 ), + array( 'one', 1 ), + array( 'other', 2 ), + array( 'other', 200 ), + ); + } + +} diff --git a/tests/phpunit/languages/LanguageKshTest.php b/tests/phpunit/languages/LanguageKshTest.php new file mode 100644 index 00000000..ab889464 --- /dev/null +++ b/tests/phpunit/languages/LanguageKshTest.php @@ -0,0 +1,34 @@ +lang = Language::factory( 'ksh' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providerPlural */ + function testPlural( $result, $value ) { + $forms = array( 'one', 'other', 'zero' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providerPlural() { + return array ( + array( 'zero', 0 ), + array( 'one', 1 ), + array( 'other', 2 ), + array( 'other', 200 ), + ); + } + +} diff --git a/tests/phpunit/languages/LanguageLnTest.php b/tests/phpunit/languages/LanguageLnTest.php new file mode 100644 index 00000000..0fd9167e --- /dev/null +++ b/tests/phpunit/languages/LanguageLnTest.php @@ -0,0 +1,34 @@ +lang = Language::factory( 'ln' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providePlural */ + function testPlural( $result, $value ) { + $forms = array( 'one', 'other' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providePlural() { + return array ( + array( 'one', 0 ), + array( 'one', 1 ), + array( 'other', 2 ), + array( 'other', 200 ), + ); + } + +} diff --git a/tests/phpunit/languages/LanguageLtTest.php b/tests/phpunit/languages/LanguageLtTest.php new file mode 100644 index 00000000..0d7c7d3e --- /dev/null +++ b/tests/phpunit/languages/LanguageLtTest.php @@ -0,0 +1,53 @@ +lang = Language::factory( 'Lt' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider provideOneFewOtherCases */ + function testOneFewOtherPlural( $result, $value ) { + $forms = array( 'one', 'few', 'other' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + /** @dataProvider provideOneFewCases */ + function testOneFewPlural( $result, $value ) { + $forms = array( 'one', 'few' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function provideOneFewOtherCases() { + return array ( + array( 'other', 0 ), + array( 'one', 1 ), + array( 'few', 2 ), + array( 'few', 9 ), + array( 'other', 10 ), + array( 'other', 11 ), + array( 'other', 20 ), + array( 'one', 21 ), + array( 'few', 32 ), + array( 'one', 41 ), + array( 'one', 40001 ), + ); + } + + function provideOneFewCases() { + return array ( + array( 'one', 1 ), + array( 'few', 15 ), + ); + } +} diff --git a/tests/phpunit/languages/LanguageLvTest.php b/tests/phpunit/languages/LanguageLvTest.php new file mode 100644 index 00000000..0636da5f --- /dev/null +++ b/tests/phpunit/languages/LanguageLvTest.php @@ -0,0 +1,39 @@ +lang = Language::factory( 'lv' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providerPlural */ + function testPlural( $result, $value ) { + $forms = array( 'one', 'other' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providerPlural() { + return array ( + array( 'other', 0 ), #this must be zero form as per CLDR + array( 'one', 1 ), + array( 'other', 11 ), + array( 'one', 21 ), + array( 'other', 411 ), + array( 'other', 12.345 ), + array( 'other', 20 ), + array( 'one', 31 ), + array( 'other', 200 ), + ); + } + +} diff --git a/tests/phpunit/languages/LanguageMgTest.php b/tests/phpunit/languages/LanguageMgTest.php new file mode 100644 index 00000000..06b56547 --- /dev/null +++ b/tests/phpunit/languages/LanguageMgTest.php @@ -0,0 +1,35 @@ +lang = Language::factory( 'mg' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providePlural */ + function testPlural( $result, $value ) { + $forms = array( 'one', 'other' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providePlural() { + return array ( + array( 'one', 0 ), + array( 'one', 1 ), + array( 'other', 2 ), + array( 'other', 200 ), + array( 'other', 123.3434 ), + ); + } + +} diff --git a/tests/phpunit/languages/LanguageMkTest.php b/tests/phpunit/languages/LanguageMkTest.php new file mode 100644 index 00000000..cf5ec3d9 --- /dev/null +++ b/tests/phpunit/languages/LanguageMkTest.php @@ -0,0 +1,41 @@ +lang = Language::factory( 'mk' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providerPlural */ + function testPlural( $result, $value ) { + $forms = array( 'one', 'other' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + + function providerPlural() { + return array ( + array( 'other', 0 ), + array( 'one', 1 ), + array( 'other', 11 ), + array( 'one', 21 ), + array( 'other', 411 ), + array( 'other', 12.345 ), + array( 'other', 20 ), + array( 'one', 31 ), + array( 'other', 200 ), + ); + } + + +} diff --git a/tests/phpunit/languages/LanguageMlTest.php b/tests/phpunit/languages/LanguageMlTest.php new file mode 100644 index 00000000..8c4b0b2f --- /dev/null +++ b/tests/phpunit/languages/LanguageMlTest.php @@ -0,0 +1,43 @@ +lang = Language::factory( 'Ml' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** see bug 29495 */ + /** @dataProvider providerFormatNum*/ + function testFormatNum( $result, $value ) { + $this->assertEquals( $result, $this->lang->formatNum( $value ) ); + } + + function providerFormatNum() { + return array( + array( '12,34,567', '1234567' ), + array( '12,345', '12345' ), + array( '1', '1' ), + array( '123', '123' ) , + array( '1,234', '1234' ), + array( '12,345.56', '12345.56' ), + array( '12,34,56,79,81,23,45,678', '12345679812345678' ), + array( '.12345', '.12345' ), + array( '-12,00,000', '-1200000' ), + array( '-98', '-98' ), + array( '-98', -98 ), + array( '-1,23,45,678', -12345678 ), + array( '', '' ), + array( '', null ), + ); + } +} diff --git a/tests/phpunit/languages/LanguageMoTest.php b/tests/phpunit/languages/LanguageMoTest.php new file mode 100644 index 00000000..533e590f --- /dev/null +++ b/tests/phpunit/languages/LanguageMoTest.php @@ -0,0 +1,43 @@ +lang = Language::factory( 'mo' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providerPlural */ + function testPlural( $result, $value ) { + $forms = array( 'one', 'few', 'other' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providerPlural() { + return array ( + array( 'few', 0 ), + array( 'one', 1 ), + array( 'few', 2 ), + array( 'few', 19 ), + array( 'other', 20 ), + array( 'other', 99 ), + array( 'other', 100 ), + array( 'few', 101 ), + array( 'few', 119 ), + array( 'other', 120 ), + array( 'other', 200 ), + array( 'few', 201 ), + array( 'few', 219 ), + array( 'other', 220 ), + ); + } +} diff --git a/tests/phpunit/languages/LanguageMtTest.php b/tests/phpunit/languages/LanguageMtTest.php new file mode 100644 index 00000000..421bb388 --- /dev/null +++ b/tests/phpunit/languages/LanguageMtTest.php @@ -0,0 +1,72 @@ +lang = Language::factory( 'mt' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providerPluralAllForms */ + function testPluralAllForms( $result, $value ) { + $forms = array( 'one', 'few', 'many', 'other' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providerPluralAllForms() { + return array ( + array( 'few', 0 ), + array( 'one', 1 ), + array( 'few', 2 ), + array( 'few', 10 ), + array( 'many', 11 ), + array( 'many', 19 ), + array( 'other', 20 ), + array( 'other', 99 ), + array( 'other', 100 ), + array( 'other', 101 ), + array( 'few', 102 ), + array( 'few', 110 ), + array( 'many', 111 ), + array( 'many', 119 ), + array( 'other', 120 ), + array( 'other', 201 ), + ); + } + + /** @dataProvider providerPluralTwoForms */ + function testPluralTwoForms( $result, $value ) { + $forms = array( 'one', 'many' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providerPluralTwoForms() { + return array ( + array( 'many', 0 ), + array( 'one', 1 ), + array( 'many', 2 ), + array( 'many', 10 ), + array( 'many', 11 ), + array( 'many', 19 ), + array( 'many', 20 ), + array( 'many', 99 ), + array( 'many', 100 ), + array( 'many', 101 ), + array( 'many', 102 ), + array( 'many', 110 ), + array( 'many', 111 ), + array( 'many', 119 ), + array( 'many', 120 ), + array( 'many', 201 ), + ); + } +} diff --git a/tests/phpunit/languages/LanguageNlTest.php b/tests/phpunit/languages/LanguageNlTest.php new file mode 100644 index 00000000..cf979cd2 --- /dev/null +++ b/tests/phpunit/languages/LanguageNlTest.php @@ -0,0 +1,28 @@ +lang = Language::factory( 'Nl' ); + } + function tearDown() { + unset( $this->lang ); + } + + function testFormatNum() { + $this->assertEquals( '1.234.567', $this->lang->formatNum( '1234567' ) ); + $this->assertEquals( '12.345', $this->lang->formatNum( '12345' ) ); + $this->assertEquals( '1', $this->lang->formatNum( '1' ) ); + $this->assertEquals( '123', $this->lang->formatNum( '123' ) ); + $this->assertEquals( '1.234', $this->lang->formatNum( '1234' ) ); + $this->assertEquals( '12.345,56', $this->lang->formatNum( '12345.56' ) ); + $this->assertEquals( ',1234556', $this->lang->formatNum( '.1234556' ) ); + } +} diff --git a/tests/phpunit/languages/LanguageNsoTest.php b/tests/phpunit/languages/LanguageNsoTest.php new file mode 100644 index 00000000..ea393628 --- /dev/null +++ b/tests/phpunit/languages/LanguageNsoTest.php @@ -0,0 +1,32 @@ +lang = Language::factory( 'nso' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providerPlural */ + function testPlural( $result, $value ) { + $forms = array( 'one', 'many' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providerPlural() { + return array ( + array( 'one', 0 ), + array( 'one', 1 ), + array( 'many', 2 ), + ); + } +} diff --git a/tests/phpunit/languages/LanguagePlTest.php b/tests/phpunit/languages/LanguagePlTest.php new file mode 100644 index 00000000..e56d4b77 --- /dev/null +++ b/tests/phpunit/languages/LanguagePlTest.php @@ -0,0 +1,72 @@ +lang = Language::factory( 'pl' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providerPluralFourForms */ + function testPluralFourForms( $result, $value ) { + $forms = array( 'one', 'few', 'many' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providerPluralFourForms() { + return array ( + array( 'many', 0 ), + array( 'one', 1 ), + array( 'few', 2 ), + array( 'few', 3 ), + array( 'few', 4 ), + array( 'many', 5 ), + array( 'many', 9 ), + array( 'many', 10 ), + array( 'many', 11 ), + array( 'many', 21 ), + array( 'few', 22 ), + array( 'few', 23 ), + array( 'few', 24 ), + array( 'many', 25 ), + array( 'many', 200 ), + array( 'many', 201 ), + ); + } + + /** @dataProvider providerPlural */ + function testPlural( $result, $value ) { + $forms = array( 'one', 'many' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providerPlural() { + return array ( + array( 'many', 0 ), + array( 'one', 1 ), + array( 'many', 2 ), + array( 'many', 3 ), + array( 'many', 4 ), + array( 'many', 5 ), + array( 'many', 9 ), + array( 'many', 10 ), + array( 'many', 11 ), + array( 'many', 21 ), + array( 'many', 22 ), + array( 'many', 23 ), + array( 'many', 24 ), + array( 'many', 25 ), + array( 'many', 200 ), + array( 'many', 201 ), + ); + } +} diff --git a/tests/phpunit/languages/LanguageRoTest.php b/tests/phpunit/languages/LanguageRoTest.php new file mode 100644 index 00000000..5270f6fe --- /dev/null +++ b/tests/phpunit/languages/LanguageRoTest.php @@ -0,0 +1,43 @@ +lang = Language::factory( 'ro' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providerPlural */ + function testPlural( $result, $value ) { + $forms = array( 'one', 'few', 'other' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providerPlural() { + return array ( + array( 'few', 0 ), + array( 'one', 1 ), + array( 'few', 2 ), + array( 'few', 19 ), + array( 'other', 20 ), + array( 'other', 99 ), + array( 'other', 100 ), + array( 'few', 101 ), + array( 'few', 119 ), + array( 'other', 120 ), + array( 'other', 200 ), + array( 'few', 201 ), + array( 'few', 219 ), + array( 'other', 220 ), + ); + } +} diff --git a/tests/phpunit/languages/LanguageRuTest.php b/tests/phpunit/languages/LanguageRuTest.php new file mode 100644 index 00000000..7a1f193b --- /dev/null +++ b/tests/phpunit/languages/LanguageRuTest.php @@ -0,0 +1,54 @@ +lang = Language::factory( 'ru' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providePluralFourForms */ + function testPluralFourForms( $result, $value ) { + $forms = array( 'one', 'few', 'many', 'other' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providePluralFourForms() { + return array ( + array( 'one', 1 ), + array( 'many', 11 ), + array( 'one', 91 ), + array( 'one', 121 ), + array( 'few', 2 ), + array( 'few', 3 ), + array( 'few', 4 ), + array( 'few', 334 ), + array( 'many', 5 ), + array( 'many', 15 ), + array( 'many', 120 ), + ); + } + /** @dataProvider providePluralTwoForms */ + function testPluralTwoForms( $result, $value ) { + $forms = array( 'one', 'several' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + function providePluralTwoForms() { + return array ( + array( 'one', 1 ), + array( 'several', 11 ), + array( 'several', 91 ), + array( 'several', 121 ), + ); + } +} diff --git a/tests/phpunit/languages/LanguageSeTest.php b/tests/phpunit/languages/LanguageSeTest.php new file mode 100644 index 00000000..065ec29e --- /dev/null +++ b/tests/phpunit/languages/LanguageSeTest.php @@ -0,0 +1,48 @@ +lang = Language::factory( 'se' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providerPluralThreeForms */ + function testPluralThreeForms( $result, $value ) { + $forms = array( 'one', 'two', 'other' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providerPluralThreeForms() { + return array ( + array( 'other', 0 ), + array( 'one', 1 ), + array( 'two', 2 ), + array( 'other', 3 ), + ); + } + + /** @dataProvider providerPlural */ + function testPlural( $result, $value ) { + $forms = array( 'one', 'other' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providerPlural() { + return array ( + array( 'other', 0 ), + array( 'one', 1 ), + array( 'other', 2 ), + array( 'other', 3 ), + ); + } +} diff --git a/tests/phpunit/languages/LanguageSgsTest.php b/tests/phpunit/languages/LanguageSgsTest.php new file mode 100644 index 00000000..931c82f0 --- /dev/null +++ b/tests/phpunit/languages/LanguageSgsTest.php @@ -0,0 +1,66 @@ +lang = Language::factory( 'Sgs' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providePluralAllForms */ + function testPluralAllForms( $result, $value ) { + $forms = array( 'one', 'few', 'many', 'other' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providePluralAllForms() { + return array ( + array( 'many', 0 ), + array( 'one', 1 ), + array( 'few', 2 ), + array( 'other', 3 ), + array( 'many', 10 ), + array( 'many', 11 ), + array( 'many', 12 ), + array( 'many', 19 ), + array( 'other', 20 ), + array( 'many', 100 ), + array( 'one', 101 ), + array( 'many', 111 ), + array( 'many', 112 ), + ); + } + + /** @dataProvider providePluralTwoForms */ + function testPluralTwoForms( $result, $value ) { + $forms = array( 'one', 'other' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providePluralTwoForms() { + return array ( + array( 'other', 0 ), + array( 'one', 1 ), + array( 'other', 2 ), + array( 'other', 3 ), + array( 'other', 10 ), + array( 'other', 11 ), + array( 'other', 12 ), + array( 'other', 19 ), + array( 'other', 20 ), + array( 'other', 100 ), + array( 'one', 101 ), + array( 'other', 111 ), + array( 'other', 112 ), + ); + } +} diff --git a/tests/phpunit/languages/LanguageShTest.php b/tests/phpunit/languages/LanguageShTest.php new file mode 100644 index 00000000..b8169aed --- /dev/null +++ b/tests/phpunit/languages/LanguageShTest.php @@ -0,0 +1,32 @@ +lang = Language::factory( 'sh' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providerPlural */ + function testPlural( $result, $value ) { + $forms = array( 'one', 'many' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providerPlural() { + return array ( + array( 'many', 0 ), + array( 'one', 1 ), + array( 'many', 2 ), + ); + } +} diff --git a/tests/phpunit/languages/LanguageSkTest.php b/tests/phpunit/languages/LanguageSkTest.php new file mode 100644 index 00000000..4cfd840e --- /dev/null +++ b/tests/phpunit/languages/LanguageSkTest.php @@ -0,0 +1,40 @@ +lang = Language::factory( 'sk' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providerPlural */ + function testPlural( $result, $value ) { + $forms = array( 'one', 'few', 'other' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providerPlural() { + return array ( + array( 'other', 0 ), + array( 'one', 1 ), + array( 'few', 2 ), + array( 'few', 3 ), + array( 'few', 4 ), + array( 'other', 5 ), + array( 'other', 11 ), + array( 'other', 20 ), + array( 'other', 25 ), + array( 'other', 200 ), + ); + } +} diff --git a/tests/phpunit/languages/LanguageSlTest.php b/tests/phpunit/languages/LanguageSlTest.php new file mode 100644 index 00000000..c1f75691 --- /dev/null +++ b/tests/phpunit/languages/LanguageSlTest.php @@ -0,0 +1,42 @@ +lang = Language::factory( 'sl' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providerPlural */ + function testPlural( $result, $value ) { + $forms = array( 'one', 'two', 'few', 'other', 'zero' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providerPlural() { + return array ( + array( 'zero', 0 ), + array( 'one', 1 ), + array( 'two', 2 ), + array( 'few', 3 ), + array( 'few', 4 ), + array( 'other', 5 ), + array( 'other', 99 ), + array( 'other', 100 ), + array( 'one', 101 ), + array( 'two', 102 ), + array( 'few', 103 ), + array( 'one', 201 ), + ); + } +} diff --git a/tests/phpunit/languages/LanguageSmaTest.php b/tests/phpunit/languages/LanguageSmaTest.php new file mode 100644 index 00000000..b7e72e97 --- /dev/null +++ b/tests/phpunit/languages/LanguageSmaTest.php @@ -0,0 +1,48 @@ +lang = Language::factory( 'sma' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providerPluralThreeForms */ + function testPluralThreeForms( $result, $value ) { + $forms = array( 'one', 'two', 'other' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providerPluralThreeForms() { + return array ( + array( 'other', 0 ), + array( 'one', 1 ), + array( 'two', 2 ), + array( 'other', 3 ), + ); + } + + /** @dataProvider providerPlural */ + function testPlural( $result, $value ) { + $forms = array( 'one', 'other' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providerPlural() { + return array ( + array( 'other', 0 ), + array( 'one', 1 ), + array( 'other', 2 ), + array( 'other', 3 ), + ); + } +} diff --git a/tests/phpunit/languages/LanguageSrTest.php b/tests/phpunit/languages/LanguageSrTest.php new file mode 100644 index 00000000..a50547c6 --- /dev/null +++ b/tests/phpunit/languages/LanguageSrTest.php @@ -0,0 +1,199 @@ + + * @copyright Copyright © 2011, Antoine Musso + * @file + */ + +require_once dirname( dirname( __FILE__ ) ) . '/bootstrap.php'; + +/** Tests for MediaWiki languages/LanguageTr.php */ +class LanguageSrTest extends MediaWikiTestCase { + /* Language object. Initialized before each test */ + private $lang; + + function setUp() { + $this->lang = Language::factory( 'sr' ); + } + function tearDown() { + unset( $this->lang ); + } + + ##### TESTS ####################################################### + + function testEasyConversions( ) { + $this->assertCyrillic( + 'шђчћжШЂЧЋЖ', + 'Cyrillic guessing characters' + ); + $this->assertLatin( + 'šđč枊ĐČĆŽ', + 'Latin guessing characters' + ); + } + + function testMixedConversions() { + $this->assertCyrillic( + 'шђчћжШЂЧЋЖ - šđčćž', + 'Mostly cyrillic characters' + ); + $this->assertLatin( + 'šđč枊ĐČĆŽ - шђчћж', + 'Mostly latin characters' + ); + } + + function testSameAmountOfLatinAndCyrillicGetConverted() { + $this->assertConverted( + '4 latin: šđčć | 4 cyrillic: шђчћ', + 'sr-ec' + ); + $this->assertConverted( + '4 latin: šđčć | 4 cyrillic: шђчћ', + 'sr-el' + ); + } + + /** + * @author Nikola Smolenski + */ + function testConversionToCyrillic() { + $this->assertEquals( 'абвг', + $this->convertToCyrillic( 'abvg' ) + ); + $this->assertEquals( 'абвг', + $this->convertToCyrillic( 'абвг' ) + ); + $this->assertEquals( 'abvgшђжчћ', + $this->convertToCyrillic( 'abvgшђжчћ' ) + ); + $this->assertEquals( 'абвгшђжчћ', + $this->convertToCyrillic( 'абвгšđžčć' ) + ); + // Roman numerals are not converted + $this->assertEquals( 'а I б II в III г IV шђжчћ', + $this->convertToCyrillic( 'a I b II v III g IV šđžčć' ) + ); + } + + function testConversionToLatin() { + $this->assertEquals( 'abcd', + $this->convertToLatin( 'abcd' ) + ); + $this->assertEquals( 'abcd', + $this->convertToLatin( 'абцд' ) + ); + $this->assertEquals( 'abcdšđžčć', + $this->convertToLatin( 'abcdшђжчћ' ) + ); + $this->assertEquals( 'абцдšđžčć', + $this->convertToLatin( 'абцдšđžčć' ) + ); + } + + /** @dataProvider providePluralFourForms */ + function testPluralFourForms( $result, $value ) { + $forms = array( 'one', 'few', 'many', 'other' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providePluralFourForms() { + return array ( + array( 'one', 1 ), + array( 'many', 11 ), + array( 'one', 91 ), + array( 'one', 121 ), + array( 'few', 2 ), + array( 'few', 3 ), + array( 'few', 4 ), + array( 'few', 334 ), + array( 'many', 5 ), + array( 'many', 15 ), + array( 'many', 120 ), + ); + } + /** @dataProvider providePluralTwoForms */ + function testPluralTwoForms( $result, $value ) { + $forms = array( 'one', 'several' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + function providePluralTwoForms() { + return array ( + array( 'one', 1 ), + array( 'several', 11 ), + array( 'several', 91 ), + array( 'several', 121 ), + ); + } + + ##### HELPERS ##################################################### + /** + *Wrapper to verify text stay the same after applying conversion + * @param $text string Text to convert + * @param $variant string Language variant 'sr-ec' or 'sr-el' + * @param $msg string Optional message + */ + function assertUnConverted( $text, $variant, $msg = '' ) { + $this->assertEquals( + $text, + $this->convertTo( $text, $variant ), + $msg + ); + } + /** + * Wrapper to verify a text is different once converted to a variant. + * @param $text string Text to convert + * @param $variant string Language variant 'sr-ec' or 'sr-el' + * @param $msg string Optional message + */ + function assertConverted( $text, $variant, $msg = '' ) { + $this->assertNotEquals( + $text, + $this->convertTo( $text, $variant ), + $msg + ); + } + + /** + * Verifiy the given Cyrillic text is not converted when using + * using the cyrillic variant and converted to Latin when using + * the Latin variant. + */ + function assertCyrillic( $text, $msg = '' ) { + $this->assertUnConverted( $text, 'sr-ec', $msg ); + $this->assertConverted( $text, 'sr-el', $msg ); + } + /** + * Verifiy the given Latin text is not converted when using + * using the Latin variant and converted to Cyrillic when using + * the Cyrillic variant. + */ + function assertLatin( $text, $msg = '' ) { + $this->assertUnConverted( $text, 'sr-el', $msg ); + $this->assertConverted( $text, 'sr-ec', $msg ); + } + + + /** Wrapper for converter::convertTo() method*/ + function convertTo( $text, $variant ) { + return $this + ->lang + ->mConverter + ->convertTo( + $text, $variant + ); + } + function convertToCyrillic( $text ) { + return $this->convertTo( $text, 'sr-ec' ); + } + function convertToLatin( $text ) { + return $this->convertTo( $text, 'sr-el' ); + } +} diff --git a/tests/phpunit/languages/LanguageTest.php b/tests/phpunit/languages/LanguageTest.php index aaad9c31..c83e01ea 100644 --- a/tests/phpunit/languages/LanguageTest.php +++ b/tests/phpunit/languages/LanguageTest.php @@ -1,6 +1,10 @@ assertEquals( - "9.5s", - $this->lang->formatTimePeriod( 9.45 ), - 'formatTimePeriod() rounding (<10s)' - ); - - $this->assertEquals( - "10s", - $this->lang->formatTimePeriod( 9.95 ), - 'formatTimePeriod() rounding (<10s)' - ); - - $this->assertEquals( - "1m 0s", - $this->lang->formatTimePeriod( 59.55 ), - 'formatTimePeriod() rounding (<60s)' - ); - - $this->assertEquals( - "2m 0s", - $this->lang->formatTimePeriod( 119.55 ), - 'formatTimePeriod() rounding (<1h)' - ); - - $this->assertEquals( - "1h 0m 0s", - $this->lang->formatTimePeriod( 3599.55 ), - 'formatTimePeriod() rounding (<1h)' - ); - - $this->assertEquals( - "2h 0m 0s", - $this->lang->formatTimePeriod( 7199.55 ), - 'formatTimePeriod() rounding (>=1h)' - ); - - $this->assertEquals( - "2h 0m", - $this->lang->formatTimePeriod( 7199.55, 'avoidseconds' ), - 'formatTimePeriod() rounding (>=1h), avoidseconds' - ); - - $this->assertEquals( - "2h 0m", - $this->lang->formatTimePeriod( 7199.55, 'avoidminutes' ), - 'formatTimePeriod() rounding (>=1h), avoidminutes' - ); - - $this->assertEquals( - "48h 0m", - $this->lang->formatTimePeriod( 172799.55, 'avoidseconds' ), - 'formatTimePeriod() rounding (=48h), avoidseconds' - ); - - $this->assertEquals( - "3d 0h", - $this->lang->formatTimePeriod( 259199.55, 'avoidminutes' ), - 'formatTimePeriod() rounding (>48h), avoidminutes' - ); - - $this->assertEquals( - "2d 1h 0m", - $this->lang->formatTimePeriod( 176399.55, 'avoidseconds' ), - 'formatTimePeriod() rounding (>48h), avoidseconds' - ); - - $this->assertEquals( - "2d 1h", - $this->lang->formatTimePeriod( 176399.55, 'avoidminutes' ), - 'formatTimePeriod() rounding (>48h), avoidminutes' - ); - - $this->assertEquals( - "3d 0h 0m", - $this->lang->formatTimePeriod( 259199.55, 'avoidseconds' ), - 'formatTimePeriod() rounding (>48h), avoidminutes' - ); - - $this->assertEquals( - "2d 0h 0m", - $this->lang->formatTimePeriod( 172801.55, 'avoidseconds' ), - 'formatTimePeriod() rounding, (>48h), avoidseconds' - ); - - $this->assertEquals( - "2d 1h 1m 1s", - $this->lang->formatTimePeriod( 176460.55 ), - 'formatTimePeriod() rounding, recursion, (>48h)' + + /** @dataProvider provideFormattableTimes */ + function testFormatTimePeriod( $seconds, $format, $expected, $desc ) { + $this->assertEquals( $expected, $this->lang->formatTimePeriod( $seconds, $format ), $desc ); + } + + function provideFormattableTimes() { + return array( + array( 9.45, array(), '9.5s', 'formatTimePeriod() rounding (<10s)' ), + array( 9.45, array( 'noabbrevs' => true ), '9.5 seconds', 'formatTimePeriod() rounding (<10s)' ), + array( 9.95, array(), '10s', 'formatTimePeriod() rounding (<10s)' ), + array( 9.95, array( 'noabbrevs' => true ), '10 seconds', 'formatTimePeriod() rounding (<10s)' ), + array( 59.55, array(), '1m 0s', 'formatTimePeriod() rounding (<60s)' ), + array( 59.55, array( 'noabbrevs' => true ), '1 minute 0 seconds', 'formatTimePeriod() rounding (<60s)' ), + array( 119.55, array(), '2m 0s', 'formatTimePeriod() rounding (<1h)' ), + array( 119.55, array( 'noabbrevs' => true ), '2 minutes 0 seconds', 'formatTimePeriod() rounding (<1h)' ), + array( 3599.55, array(), '1h 0m 0s', 'formatTimePeriod() rounding (<1h)' ), + array( 3599.55, array( 'noabbrevs' => true ), '1 hour 0 minutes 0 seconds', 'formatTimePeriod() rounding (<1h)' ), + array( 7199.55, array(), '2h 0m 0s', 'formatTimePeriod() rounding (>=1h)' ), + array( 7199.55, array( 'noabbrevs' => true ), '2 hours 0 minutes 0 seconds', 'formatTimePeriod() rounding (>=1h)' ), + array( 7199.55, 'avoidseconds', '2h 0m', 'formatTimePeriod() rounding (>=1h), avoidseconds' ), + array( 7199.55, array( 'avoid' => 'avoidseconds', 'noabbrevs' => true ), '2 hours 0 minutes', 'formatTimePeriod() rounding (>=1h), avoidseconds' ), + array( 7199.55, 'avoidminutes', '2h 0m', 'formatTimePeriod() rounding (>=1h), avoidminutes' ), + array( 7199.55, array( 'avoid' => 'avoidminutes', 'noabbrevs' => true ), '2 hours 0 minutes', 'formatTimePeriod() rounding (>=1h), avoidminutes' ), + array( 172799.55, 'avoidseconds', '48h 0m', 'formatTimePeriod() rounding (=48h), avoidseconds' ), + array( 172799.55, array( 'avoid' => 'avoidseconds', 'noabbrevs' => true ), '48 hours 0 minutes', 'formatTimePeriod() rounding (=48h), avoidseconds' ), + array( 259199.55, 'avoidminutes', '3d 0h', 'formatTimePeriod() rounding (>48h), avoidminutes' ), + array( 259199.55, array( 'avoid' => 'avoidminutes', 'noabbrevs' => true ), '3 days 0 hours', 'formatTimePeriod() rounding (>48h), avoidminutes' ), + array( 176399.55, 'avoidseconds', '2d 1h 0m', 'formatTimePeriod() rounding (>48h), avoidseconds' ), + array( 176399.55, array( 'avoid' => 'avoidseconds', 'noabbrevs' => true ), '2 days 1 hour 0 minutes', 'formatTimePeriod() rounding (>48h), avoidseconds' ), + array( 176399.55, 'avoidminutes', '2d 1h', 'formatTimePeriod() rounding (>48h), avoidminutes' ), + array( 176399.55, array( 'avoid' => 'avoidminutes', 'noabbrevs' => true ), '2 days 1 hour', 'formatTimePeriod() rounding (>48h), avoidminutes' ), + array( 259199.55, 'avoidseconds', '3d 0h 0m', 'formatTimePeriod() rounding (>48h), avoidseconds' ), + array( 259199.55, array( 'avoid' => 'avoidseconds', 'noabbrevs' => true ), '3 days 0 hours 0 minutes', 'formatTimePeriod() rounding (>48h), avoidseconds' ), + array( 172801.55, 'avoidseconds', '2d 0h 0m', 'formatTimePeriod() rounding, (>48h), avoidseconds' ), + array( 172801.55, array( 'avoid' => 'avoidseconds', 'noabbrevs' => true ), '2 days 0 hours 0 minutes', 'formatTimePeriod() rounding, (>48h), avoidseconds' ), + array( 176460.55, array(), '2d 1h 1m 1s', 'formatTimePeriod() rounding, recursion, (>48h)' ), + array( 176460.55, array( 'noabbrevs' => true ), '2 days 1 hour 1 minute 1 second', 'formatTimePeriod() rounding, recursion, (>48h)' ), ); + } function testTruncate() { @@ -243,4 +196,462 @@ class LanguageTest extends MediaWikiTestCase { array( 'Be-x-old', 'With extension (two dashes)' ), ); } + + /** + * @dataProvider provideSprintfDateSamples + */ + function testSprintfDate( $format, $ts, $expected, $msg ) { + $this->assertEquals( + $expected, + $this->lang->sprintfDate( $format, $ts ), + "sprintfDate('$format', '$ts'): $msg" + ); + } + /** + * bug 33454. sprintfDate should always use UTC. + * @dataProvider provideSprintfDateSamples + */ + function testSprintfDateTZ( $format, $ts, $expected, $msg ) { + $oldTZ = date_default_timezone_get(); + $res = date_default_timezone_set( 'Asia/Seoul' ); + if ( !$res ) { + $this->markTestSkipped( "Error setting Timezone" ); + } + + $this->assertEquals( + $expected, + $this->lang->sprintfDate( $format, $ts ), + "sprintfDate('$format', '$ts'): $msg" + ); + + date_default_timezone_set( $oldTZ ); + } + + function provideSprintfDateSamples() { + return array( + array( + 'xiY', + '20111212000000', + '1390', // note because we're testing English locale we get Latin-standard digits + 'Iranian calendar full year' + ), + array( + 'xiy', + '20111212000000', + '90', + 'Iranian calendar short year' + ), + array( + 'o', + '20120101235000', + '2011', + 'ISO 8601 (week) year' + ), + array( + 'W', + '20120101235000', + '52', + 'Week number' + ), + array( + 'W', + '20120102235000', + '1', + 'Week number' + ), + array( + 'o-\\WW-N', + '20091231235000', + '2009-W53-4', + 'leap week' + ), + // What follows is mostly copied from http://www.mediawiki.org/wiki/Help:Extension:ParserFunctions#.23time + array( + 'Y', + '20120102090705', + '2012', + 'Full year' + ), + array( + 'y', + '20120102090705', + '12', + '2 digit year' + ), + array( + 'L', + '20120102090705', + '1', + 'Leap year' + ), + array( + 'n', + '20120102090705', + '1', + 'Month index, not zero pad' + ), + array( + 'N', + '20120102090705', + '01', + 'Month index. Zero pad' + ), + array( + 'M', + '20120102090705', + 'Jan', + 'Month abbrev' + ), + array( + 'F', + '20120102090705', + 'January', + 'Full month' + ), + array( + 'xg', + '20120102090705', + 'January', + 'Genitive month name (same in EN)' + ), + array( + 'j', + '20120102090705', + '2', + 'Day of month (not zero pad)' + ), + array( + 'd', + '20120102090705', + '02', + 'Day of month (zero-pad)' + ), + array( + 'z', + '20120102090705', + '1', + 'Day of year (zero-indexed)' + ), + array( + 'D', + '20120102090705', + 'Mon', + 'Day of week (abbrev)' + ), + array( + 'l', + '20120102090705', + 'Monday', + 'Full day of week' + ), + array( + 'N', + '20120101090705', + '7', + 'Day of week (Mon=1, Sun=7)' + ), + array( + 'w', + '20120101090705', + '0', + 'Day of week (Sun=0, Sat=6)' + ), + array( + 'N', + '20120102090705', + '1', + 'Day of week' + ), + array( + 'a', + '20120102090705', + 'am', + 'am vs pm' + ), + array( + 'A', + '20120102120000', + 'PM', + 'AM vs PM' + ), + array( + 'a', + '20120102000000', + 'am', + 'AM vs PM' + ), + array( + 'g', + '20120102090705', + '9', + '12 hour, not Zero' + ), + array( + 'h', + '20120102090705', + '09', + '12 hour, zero padded' + ), + array( + 'G', + '20120102090705', + '9', + '24 hour, not zero' + ), + array( + 'H', + '20120102090705', + '09', + '24 hour, zero' + ), + array( + 'H', + '20120102110705', + '11', + '24 hour, zero' + ), + array( + 'i', + '20120102090705', + '07', + 'Minutes' + ), + array( + 's', + '20120102090705', + '05', + 'seconds' + ), + array( + 'U', + '20120102090705', + '1325495225', + 'unix time' + ), + array( + 't', + '20120102090705', + '31', + 'Days in current month' + ), + array( + 'c', + '20120102090705', + '2012-01-02T09:07:05+00:00', + 'ISO 8601 timestamp' + ), + array( + 'r', + '20120102090705', + 'Mon, 02 Jan 2012 09:07:05 +0000', + 'RFC 5322' + ), + array( + 'xmj xmF xmn xmY', + '20120102090705', + '7 Safar 2 1433', + 'Islamic' + ), + array( + 'xij xiF xin xiY', + '20120102090705', + '12 Dey 10 1390', + 'Iranian' + ), + array( + 'xjj xjF xjn xjY', + '20120102090705', + '7 Tevet 4 5772', + 'Hebrew' + ), + array( + 'xjt', + '20120102090705', + '29', + 'Hebrew number of days in month' + ), + array( + 'xjx', + '20120102090705', + 'Tevet', + 'Hebrew genitive month name (No difference in EN)' + ), + array( + 'xkY', + '20120102090705', + '2555', + 'Thai year' + ), + array( + 'xoY', + '20120102090705', + '101', + 'Minguo' + ), + array( + 'xtY', + '20120102090705', + '平成24', + 'nengo' + ), + array( + 'xrxkYY', + '20120102090705', + 'MMDLV2012', + 'Roman numerals' + ), + array( + 'xhxjYY', + '20120102090705', + 'ה\'תשע"ב2012', + 'Hebrew numberals' + ), + array( + 'xnY', + '20120102090705', + '2012', + 'Raw numerals (doesn\'t mean much in EN)' + ), + array( + '[[Y "(yea"\\r)]] \\"xx\\"', + '20120102090705', + '[[2012 (year)]] "x"', + 'Various escaping' + ), + + ); + } + + /** + * @dataProvider provideFormatSizes + */ + function testFormatSize( $size, $expected, $msg ) { + $this->assertEquals( + $expected, + $this->lang->formatSize( $size ), + "formatSize('$size'): $msg" + ); + } + + function provideFormatSizes() { + return array( + array( + 0, + "0 B", + "Zero bytes" + ), + array( + 1024, + "1 KB", + "1 kilobyte" + ), + array( + 1024 * 1024, + "1 MB", + "1,024 megabytes" + ), + array( + 1024 * 1024 * 1024, + "1 GB", + "1 gigabytes" + ), + array( + pow( 1024, 4 ), + "1 TB", + "1 terabyte" + ), + array( + pow( 1024, 5 ), + "1 PB", + "1 petabyte" + ), + array( + pow( 1024, 6 ), + "1 EB", + "1,024 exabyte" + ), + array( + pow( 1024, 7 ), + "1 ZB", + "1 zetabyte" + ), + array( + pow( 1024, 8 ), + "1 YB", + "1 yottabyte" + ), + // How big!? THIS BIG! + ); + } + + /** + * @dataProvider provideFormatBitrate + */ + function testFormatBitrate( $bps, $expected, $msg ) { + $this->assertEquals( + $expected, + $this->lang->formatBitrate( $bps ), + "formatBitrate('$bps'): $msg" + ); + } + + function provideFormatBitrate() { + return array( + array( + 0, + "0bps", + "0 bits per second" + ), + array( + 999, + "999bps", + "999 bits per second" + ), + array( + 1000, + "1kbps", + "1 kilobit per second" + ), + array( + 1000 * 1000, + "1Mbps", + "1 megabit per second" + ), + array( + pow( 10, 9 ), + "1Gbps", + "1 gigabit per second" + ), + array( + pow( 10, 12 ), + "1Tbps", + "1 terabit per second" + ), + array( + pow( 10, 15 ), + "1Pbps", + "1 petabit per second" + ), + array( + pow( 10, 18 ), + "1Ebps", + "1 exabit per second" + ), + array( + pow( 10, 21 ), + "1Zbps", + "1 zetabit per second" + ), + array( + pow( 10, 24 ), + "1Ybps", + "1 yottabit per second" + ), + array( + pow( 10, 27 ), + "1,000Ybps", + "1,000 yottabits per second" + ), + ); + } } diff --git a/tests/phpunit/languages/LanguageTiTest.php b/tests/phpunit/languages/LanguageTiTest.php new file mode 100644 index 00000000..4bfaa009 --- /dev/null +++ b/tests/phpunit/languages/LanguageTiTest.php @@ -0,0 +1,32 @@ +lang = Language::factory( 'Ti' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providerPlural */ + function testPlural( $result, $value ) { + $forms = array( 'one', 'many' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providerPlural() { + return array ( + array( 'one', 0 ), + array( 'one', 1 ), + array( 'many', 2 ), + ); + } +} diff --git a/tests/phpunit/languages/LanguageTlTest.php b/tests/phpunit/languages/LanguageTlTest.php new file mode 100644 index 00000000..a1facd14 --- /dev/null +++ b/tests/phpunit/languages/LanguageTlTest.php @@ -0,0 +1,32 @@ +lang = Language::factory( 'Tl' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providerPlural */ + function testPlural( $result, $value ) { + $forms = array( 'one', 'many' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providerPlural() { + return array ( + array( 'one', 0 ), + array( 'one', 1 ), + array( 'many', 2 ), + ); + } +} diff --git a/tests/phpunit/languages/LanguageTrTest.php b/tests/phpunit/languages/LanguageTrTest.php index d2a5ff36..bda4c9d9 100644 --- a/tests/phpunit/languages/LanguageTrTest.php +++ b/tests/phpunit/languages/LanguageTrTest.php @@ -1,7 +1,7 @@ lang = Language::factory( 'Uk' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providePluralFourForms */ + function testPluralFourForms( $result, $value ) { + $forms = array( 'one', 'few', 'many', 'other' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providePluralFourForms() { + return array ( + array( 'one', 1 ), + array( 'many', 11 ), + array( 'one', 91 ), + array( 'one', 121 ), + array( 'few', 2 ), + array( 'few', 3 ), + array( 'few', 4 ), + array( 'few', 334 ), + array( 'many', 5 ), + array( 'many', 15 ), + array( 'many', 120 ), + ); + } + /** @dataProvider providePluralTwoForms */ + function testPluralTwoForms( $result, $value ) { + $forms = array( 'one', 'several' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + function providePluralTwoForms() { + return array ( + array( 'one', 1 ), + array( 'several', 11 ), + array( 'several', 91 ), + array( 'several', 121 ), + ); + } +} diff --git a/tests/phpunit/languages/LanguageWaTest.php b/tests/phpunit/languages/LanguageWaTest.php new file mode 100644 index 00000000..172f19b9 --- /dev/null +++ b/tests/phpunit/languages/LanguageWaTest.php @@ -0,0 +1,32 @@ +lang = Language::factory( 'Wa' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providerPlural */ + function testPlural( $result, $value ) { + $forms = array( 'one', 'many' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + function providerPlural() { + return array ( + array( 'one', 0 ), + array( 'one', 1 ), + array( 'many', 2 ), + ); + } +} -- cgit v1.2.2