From f6d65e533c62f6deb21342d4901ece24497b433e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 4 Jun 2015 07:31:04 +0200 Subject: Update to MediaWiki 1.25.1 --- tests/phpunit/languages/LanguageAmTest.php | 35 --- tests/phpunit/languages/LanguageArTest.php | 87 ------- tests/phpunit/languages/LanguageArqTest.php | 26 --- tests/phpunit/languages/LanguageBeTest.php | 42 ---- tests/phpunit/languages/LanguageBe_taraskTest.php | 97 -------- tests/phpunit/languages/LanguageBhoTest.php | 35 --- tests/phpunit/languages/LanguageBsTest.php | 42 ---- tests/phpunit/languages/LanguageConverterTest.php | 187 ++++++++++++++++ tests/phpunit/languages/LanguageCsTest.php | 41 ---- tests/phpunit/languages/LanguageCuTest.php | 42 ---- tests/phpunit/languages/LanguageCyTest.php | 43 ---- tests/phpunit/languages/LanguageDsbTest.php | 41 ---- tests/phpunit/languages/LanguageFrTest.php | 35 --- tests/phpunit/languages/LanguageGaTest.php | 35 --- tests/phpunit/languages/LanguageGdTest.php | 53 ----- tests/phpunit/languages/LanguageGvTest.php | 44 ---- tests/phpunit/languages/LanguageHeTest.php | 132 ----------- tests/phpunit/languages/LanguageHiTest.php | 35 --- tests/phpunit/languages/LanguageHrTest.php | 42 ---- tests/phpunit/languages/LanguageHsbTest.php | 41 ---- tests/phpunit/languages/LanguageHuTest.php | 35 --- tests/phpunit/languages/LanguageHyTest.php | 35 --- tests/phpunit/languages/LanguageKshTest.php | 35 --- tests/phpunit/languages/LanguageLnTest.php | 35 --- tests/phpunit/languages/LanguageLtTest.php | 63 ------ tests/phpunit/languages/LanguageLvTest.php | 44 ---- tests/phpunit/languages/LanguageMgTest.php | 36 --- tests/phpunit/languages/LanguageMkTest.php | 40 ---- tests/phpunit/languages/LanguageMlTest.php | 38 ---- tests/phpunit/languages/LanguageMoTest.php | 45 ---- tests/phpunit/languages/LanguageMtTest.php | 77 ------- tests/phpunit/languages/LanguageNlTest.php | 24 -- tests/phpunit/languages/LanguageNsoTest.php | 34 --- tests/phpunit/languages/LanguagePlTest.php | 77 ------- tests/phpunit/languages/LanguageRoTest.php | 45 ---- tests/phpunit/languages/LanguageRuTest.php | 115 ---------- tests/phpunit/languages/LanguageSeTest.php | 53 ----- tests/phpunit/languages/LanguageSgsTest.php | 71 ------ tests/phpunit/languages/LanguageShTest.php | 42 ---- tests/phpunit/languages/LanguageSkTest.php | 42 ---- tests/phpunit/languages/LanguageSlTest.php | 44 ---- tests/phpunit/languages/LanguageSmaTest.php | 53 ----- tests/phpunit/languages/LanguageSrTest.php | 249 --------------------- tests/phpunit/languages/LanguageTiTest.php | 34 --- tests/phpunit/languages/LanguageTlTest.php | 34 --- tests/phpunit/languages/LanguageTrTest.php | 61 ----- tests/phpunit/languages/LanguageUkTest.php | 72 ------ tests/phpunit/languages/LanguageUzTest.php | 124 ---------- tests/phpunit/languages/LanguageWaTest.php | 34 --- tests/phpunit/languages/SpecialPageAliasTest.php | 1 - tests/phpunit/languages/classes/LanguageAmTest.php | 35 +++ tests/phpunit/languages/classes/LanguageArTest.php | 87 +++++++ .../phpunit/languages/classes/LanguageArqTest.php | 26 +++ tests/phpunit/languages/classes/LanguageBeTest.php | 42 ++++ .../languages/classes/LanguageBe_taraskTest.php | 97 ++++++++ .../phpunit/languages/classes/LanguageBhoTest.php | 35 +++ tests/phpunit/languages/classes/LanguageBsTest.php | 42 ++++ tests/phpunit/languages/classes/LanguageCsTest.php | 41 ++++ tests/phpunit/languages/classes/LanguageCuTest.php | 42 ++++ tests/phpunit/languages/classes/LanguageCyTest.php | 43 ++++ .../phpunit/languages/classes/LanguageDsbTest.php | 41 ++++ tests/phpunit/languages/classes/LanguageFrTest.php | 35 +++ tests/phpunit/languages/classes/LanguageGaTest.php | 35 +++ tests/phpunit/languages/classes/LanguageGdTest.php | 53 +++++ tests/phpunit/languages/classes/LanguageGvTest.php | 44 ++++ tests/phpunit/languages/classes/LanguageHeTest.php | 132 +++++++++++ tests/phpunit/languages/classes/LanguageHiTest.php | 35 +++ tests/phpunit/languages/classes/LanguageHrTest.php | 42 ++++ .../phpunit/languages/classes/LanguageHsbTest.php | 41 ++++ tests/phpunit/languages/classes/LanguageHuTest.php | 35 +++ tests/phpunit/languages/classes/LanguageHyTest.php | 35 +++ .../phpunit/languages/classes/LanguageKshTest.php | 35 +++ tests/phpunit/languages/classes/LanguageLnTest.php | 35 +++ tests/phpunit/languages/classes/LanguageLtTest.php | 63 ++++++ tests/phpunit/languages/classes/LanguageLvTest.php | 44 ++++ tests/phpunit/languages/classes/LanguageMgTest.php | 36 +++ tests/phpunit/languages/classes/LanguageMkTest.php | 40 ++++ tests/phpunit/languages/classes/LanguageMlTest.php | 38 ++++ tests/phpunit/languages/classes/LanguageMoTest.php | 45 ++++ tests/phpunit/languages/classes/LanguageMtTest.php | 77 +++++++ tests/phpunit/languages/classes/LanguageNlTest.php | 24 ++ .../phpunit/languages/classes/LanguageNsoTest.php | 34 +++ tests/phpunit/languages/classes/LanguagePlTest.php | 77 +++++++ tests/phpunit/languages/classes/LanguageRoTest.php | 45 ++++ tests/phpunit/languages/classes/LanguageRuTest.php | 115 ++++++++++ tests/phpunit/languages/classes/LanguageSeTest.php | 53 +++++ .../phpunit/languages/classes/LanguageSgsTest.php | 71 ++++++ tests/phpunit/languages/classes/LanguageShTest.php | 42 ++++ tests/phpunit/languages/classes/LanguageSkTest.php | 42 ++++ tests/phpunit/languages/classes/LanguageSlTest.php | 44 ++++ .../phpunit/languages/classes/LanguageSmaTest.php | 53 +++++ tests/phpunit/languages/classes/LanguageSrTest.php | 249 +++++++++++++++++++++ tests/phpunit/languages/classes/LanguageTiTest.php | 34 +++ tests/phpunit/languages/classes/LanguageTlTest.php | 36 +++ tests/phpunit/languages/classes/LanguageTrTest.php | 61 +++++ tests/phpunit/languages/classes/LanguageUkTest.php | 72 ++++++ tests/phpunit/languages/classes/LanguageUzTest.php | 124 ++++++++++ tests/phpunit/languages/classes/LanguageWaTest.php | 34 +++ 98 files changed, 2828 insertions(+), 2640 deletions(-) delete mode 100644 tests/phpunit/languages/LanguageAmTest.php delete mode 100644 tests/phpunit/languages/LanguageArTest.php delete mode 100644 tests/phpunit/languages/LanguageArqTest.php delete mode 100644 tests/phpunit/languages/LanguageBeTest.php delete mode 100644 tests/phpunit/languages/LanguageBe_taraskTest.php delete mode 100644 tests/phpunit/languages/LanguageBhoTest.php delete mode 100644 tests/phpunit/languages/LanguageBsTest.php create mode 100644 tests/phpunit/languages/LanguageConverterTest.php delete mode 100644 tests/phpunit/languages/LanguageCsTest.php delete mode 100644 tests/phpunit/languages/LanguageCuTest.php delete mode 100644 tests/phpunit/languages/LanguageCyTest.php delete mode 100644 tests/phpunit/languages/LanguageDsbTest.php delete mode 100644 tests/phpunit/languages/LanguageFrTest.php delete mode 100644 tests/phpunit/languages/LanguageGaTest.php delete mode 100644 tests/phpunit/languages/LanguageGdTest.php delete mode 100644 tests/phpunit/languages/LanguageGvTest.php delete mode 100644 tests/phpunit/languages/LanguageHeTest.php delete mode 100644 tests/phpunit/languages/LanguageHiTest.php delete mode 100644 tests/phpunit/languages/LanguageHrTest.php delete mode 100644 tests/phpunit/languages/LanguageHsbTest.php delete mode 100644 tests/phpunit/languages/LanguageHuTest.php delete mode 100644 tests/phpunit/languages/LanguageHyTest.php delete mode 100644 tests/phpunit/languages/LanguageKshTest.php delete mode 100644 tests/phpunit/languages/LanguageLnTest.php delete mode 100644 tests/phpunit/languages/LanguageLtTest.php delete mode 100644 tests/phpunit/languages/LanguageLvTest.php delete mode 100644 tests/phpunit/languages/LanguageMgTest.php delete mode 100644 tests/phpunit/languages/LanguageMkTest.php delete mode 100644 tests/phpunit/languages/LanguageMlTest.php delete mode 100644 tests/phpunit/languages/LanguageMoTest.php delete mode 100644 tests/phpunit/languages/LanguageMtTest.php delete mode 100644 tests/phpunit/languages/LanguageNlTest.php delete mode 100644 tests/phpunit/languages/LanguageNsoTest.php delete mode 100644 tests/phpunit/languages/LanguagePlTest.php delete mode 100644 tests/phpunit/languages/LanguageRoTest.php delete mode 100644 tests/phpunit/languages/LanguageRuTest.php delete mode 100644 tests/phpunit/languages/LanguageSeTest.php delete mode 100644 tests/phpunit/languages/LanguageSgsTest.php delete mode 100644 tests/phpunit/languages/LanguageShTest.php delete mode 100644 tests/phpunit/languages/LanguageSkTest.php delete mode 100644 tests/phpunit/languages/LanguageSlTest.php delete mode 100644 tests/phpunit/languages/LanguageSmaTest.php delete mode 100644 tests/phpunit/languages/LanguageSrTest.php delete mode 100644 tests/phpunit/languages/LanguageTiTest.php delete mode 100644 tests/phpunit/languages/LanguageTlTest.php delete mode 100644 tests/phpunit/languages/LanguageTrTest.php delete mode 100644 tests/phpunit/languages/LanguageUkTest.php delete mode 100644 tests/phpunit/languages/LanguageUzTest.php delete mode 100644 tests/phpunit/languages/LanguageWaTest.php create mode 100644 tests/phpunit/languages/classes/LanguageAmTest.php create mode 100644 tests/phpunit/languages/classes/LanguageArTest.php create mode 100644 tests/phpunit/languages/classes/LanguageArqTest.php create mode 100644 tests/phpunit/languages/classes/LanguageBeTest.php create mode 100644 tests/phpunit/languages/classes/LanguageBe_taraskTest.php create mode 100644 tests/phpunit/languages/classes/LanguageBhoTest.php create mode 100644 tests/phpunit/languages/classes/LanguageBsTest.php create mode 100644 tests/phpunit/languages/classes/LanguageCsTest.php create mode 100644 tests/phpunit/languages/classes/LanguageCuTest.php create mode 100644 tests/phpunit/languages/classes/LanguageCyTest.php create mode 100644 tests/phpunit/languages/classes/LanguageDsbTest.php create mode 100644 tests/phpunit/languages/classes/LanguageFrTest.php create mode 100644 tests/phpunit/languages/classes/LanguageGaTest.php create mode 100644 tests/phpunit/languages/classes/LanguageGdTest.php create mode 100644 tests/phpunit/languages/classes/LanguageGvTest.php create mode 100644 tests/phpunit/languages/classes/LanguageHeTest.php create mode 100644 tests/phpunit/languages/classes/LanguageHiTest.php create mode 100644 tests/phpunit/languages/classes/LanguageHrTest.php create mode 100644 tests/phpunit/languages/classes/LanguageHsbTest.php create mode 100644 tests/phpunit/languages/classes/LanguageHuTest.php create mode 100644 tests/phpunit/languages/classes/LanguageHyTest.php create mode 100644 tests/phpunit/languages/classes/LanguageKshTest.php create mode 100644 tests/phpunit/languages/classes/LanguageLnTest.php create mode 100644 tests/phpunit/languages/classes/LanguageLtTest.php create mode 100644 tests/phpunit/languages/classes/LanguageLvTest.php create mode 100644 tests/phpunit/languages/classes/LanguageMgTest.php create mode 100644 tests/phpunit/languages/classes/LanguageMkTest.php create mode 100644 tests/phpunit/languages/classes/LanguageMlTest.php create mode 100644 tests/phpunit/languages/classes/LanguageMoTest.php create mode 100644 tests/phpunit/languages/classes/LanguageMtTest.php create mode 100644 tests/phpunit/languages/classes/LanguageNlTest.php create mode 100644 tests/phpunit/languages/classes/LanguageNsoTest.php create mode 100644 tests/phpunit/languages/classes/LanguagePlTest.php create mode 100644 tests/phpunit/languages/classes/LanguageRoTest.php create mode 100644 tests/phpunit/languages/classes/LanguageRuTest.php create mode 100644 tests/phpunit/languages/classes/LanguageSeTest.php create mode 100644 tests/phpunit/languages/classes/LanguageSgsTest.php create mode 100644 tests/phpunit/languages/classes/LanguageShTest.php create mode 100644 tests/phpunit/languages/classes/LanguageSkTest.php create mode 100644 tests/phpunit/languages/classes/LanguageSlTest.php create mode 100644 tests/phpunit/languages/classes/LanguageSmaTest.php create mode 100644 tests/phpunit/languages/classes/LanguageSrTest.php create mode 100644 tests/phpunit/languages/classes/LanguageTiTest.php create mode 100644 tests/phpunit/languages/classes/LanguageTlTest.php create mode 100644 tests/phpunit/languages/classes/LanguageTrTest.php create mode 100644 tests/phpunit/languages/classes/LanguageUkTest.php create mode 100644 tests/phpunit/languages/classes/LanguageUzTest.php create mode 100644 tests/phpunit/languages/classes/LanguageWaTest.php (limited to 'tests/phpunit/languages') diff --git a/tests/phpunit/languages/LanguageAmTest.php b/tests/phpunit/languages/LanguageAmTest.php deleted file mode 100644 index a644f5e0..00000000 --- a/tests/phpunit/languages/LanguageAmTest.php +++ /dev/null @@ -1,35 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static 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 deleted file mode 100644 index 7b48f236..00000000 --- a/tests/phpunit/languages/LanguageArTest.php +++ /dev/null @@ -1,87 +0,0 @@ -assertEquals( '١٬٢٣٤٬٥٦٧', $this->getLang()->formatNum( '1234567' ) ); - $this->assertEquals( '-١٢٫٨٩', $this->getLang()->formatNum( -12.89 ) ); - } - - /** - * Mostly to test the raw ascii feature. - * @dataProvider providerSprintfDate - * @covers Language::sprintfDate - */ - public function testSprintfDate( $format, $date, $expected ) { - $this->assertEquals( $expected, $this->getLang()->sprintfDate( $format, $date ) ); - } - - public static 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 - * @covers Language::convertPlural - */ - public function testPlural( $result, $value ) { - $forms = array( 'zero', 'one', 'two', 'few', 'many', 'other' ); - $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static 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/LanguageArqTest.php b/tests/phpunit/languages/LanguageArqTest.php deleted file mode 100644 index 3fa56d78..00000000 --- a/tests/phpunit/languages/LanguageArqTest.php +++ /dev/null @@ -1,26 +0,0 @@ -assertEquals( $result, $this->getLang()->formatNum( $value ) ); - } - - public static function provideNumber() { - return array( - array( '1.234.567', '1234567'), - array( '-12,89', -12.89 ), - ); - } - -} diff --git a/tests/phpunit/languages/LanguageBeTest.php b/tests/phpunit/languages/LanguageBeTest.php deleted file mode 100644 index 7bd586af..00000000 --- a/tests/phpunit/languages/LanguageBeTest.php +++ /dev/null @@ -1,42 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static 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 deleted file mode 100644 index 4dd5cdd7..00000000 --- a/tests/phpunit/languages/LanguageBe_taraskTest.php +++ /dev/null @@ -1,97 +0,0 @@ -assertEquals( 'be-tarask', - $this->getLang()->getCode() - ); - } - - /** - * @see bug 23156 & r64981 - * @covers Language::commafy - */ - public function testSearchRightSingleQuotationMarkAsApostroph() { - $this->assertEquals( - "'", - $this->getLang()->normalizeForSearch( '’' ), - 'bug 23156: U+2019 conversion to U+0027' - ); - } - - /** - * @see bug 23156 & r64981 - * @covers Language::commafy - */ - public function testCommafy() { - $this->assertEquals( '1,234,567', $this->getLang()->commafy( '1234567' ) ); - $this->assertEquals( '12,345', $this->getLang()->commafy( '12345' ) ); - } - - /** - * @see bug 23156 & r64981 - * @covers Language::commafy - */ - public function testDoesNotCommafyFourDigitsNumber() { - $this->assertEquals( '1234', $this->getLang()->commafy( '1234' ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::convertPlural - */ - public function testPlural( $result, $value ) { - $forms = array( 'one', 'few', 'many', 'other' ); - $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static 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 ), - ); - } - - /** - * @dataProvider providePluralTwoForms - * @covers Language::convertPlural - */ - public function testPluralTwoForms( $result, $value ) { - $forms = array( '1=one', 'other' ); - $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - public static function providePluralTwoForms() { - return array( - array( 'other', 0 ), - array( 'one', 1 ), - array( 'other', 11 ), - array( 'other', 91 ), - array( 'other', 121 ), - ); - } -} diff --git a/tests/phpunit/languages/LanguageBhoTest.php b/tests/phpunit/languages/LanguageBhoTest.php deleted file mode 100644 index 187bfbbc..00000000 --- a/tests/phpunit/languages/LanguageBhoTest.php +++ /dev/null @@ -1,35 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static 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 deleted file mode 100644 index 7aca2ab1..00000000 --- a/tests/phpunit/languages/LanguageBsTest.php +++ /dev/null @@ -1,42 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static function providePlural() { - return array( - array( 'other', 0 ), - array( 'one', 1 ), - array( 'few', 2 ), - array( 'few', 4 ), - array( 'other', 5 ), - array( 'other', 11 ), - array( 'other', 20 ), - array( 'one', 21 ), - array( 'few', 24 ), - array( 'other', 25 ), - array( 'other', 200 ), - ); - } -} diff --git a/tests/phpunit/languages/LanguageConverterTest.php b/tests/phpunit/languages/LanguageConverterTest.php new file mode 100644 index 00000000..d4ccca99 --- /dev/null +++ b/tests/phpunit/languages/LanguageConverterTest.php @@ -0,0 +1,187 @@ +setMwGlobals( array( + 'wgContLang' => Language::factory( 'tg' ), + 'wgLanguageCode' => 'tg', + 'wgDefaultLanguageVariant' => false, + 'wgMemc' => new EmptyBagOStuff, + 'wgRequest' => new FauxRequest( array() ), + 'wgUser' => new User, + ) ); + + $this->lang = new LanguageToTest(); + $this->lc = new TestConverter( + $this->lang, 'tg', + array( 'tg', 'tg-latn' ) + ); + } + + protected function tearDown() { + unset( $this->lc ); + unset( $this->lang ); + + parent::tearDown(); + } + + /** + * @covers LanguageConverter::getPreferredVariant + */ + public function testGetPreferredVariantDefaults() { + $this->assertEquals( 'tg', $this->lc->getPreferredVariant() ); + } + + /** + * @covers LanguageConverter::getPreferredVariant + * @covers LanguageConverter::getHeaderVariant + */ + public function testGetPreferredVariantHeaders() { + global $wgRequest; + $wgRequest->setHeader( 'Accept-Language', 'tg-latn' ); + + $this->assertEquals( 'tg-latn', $this->lc->getPreferredVariant() ); + } + + /** + * @covers LanguageConverter::getPreferredVariant + * @covers LanguageConverter::getHeaderVariant + */ + public function testGetPreferredVariantHeaderWeight() { + global $wgRequest; + $wgRequest->setHeader( 'Accept-Language', 'tg;q=1' ); + + $this->assertEquals( 'tg', $this->lc->getPreferredVariant() ); + } + + /** + * @covers LanguageConverter::getPreferredVariant + * @covers LanguageConverter::getHeaderVariant + */ + public function testGetPreferredVariantHeaderWeight2() { + global $wgRequest; + $wgRequest->setHeader( 'Accept-Language', 'tg-latn;q=1' ); + + $this->assertEquals( 'tg-latn', $this->lc->getPreferredVariant() ); + } + + /** + * @covers LanguageConverter::getPreferredVariant + * @covers LanguageConverter::getHeaderVariant + */ + public function testGetPreferredVariantHeaderMulti() { + global $wgRequest; + $wgRequest->setHeader( 'Accept-Language', 'en, tg-latn;q=1' ); + + $this->assertEquals( 'tg-latn', $this->lc->getPreferredVariant() ); + } + + /** + * @covers LanguageConverter::getPreferredVariant + */ + public function testGetPreferredVariantUserOption() { + global $wgUser; + + $wgUser = new User; + $wgUser->load(); // from 'defaults' + $wgUser->mId = 1; + $wgUser->mDataLoaded = true; + $wgUser->mOptionsLoaded = true; + $wgUser->setOption( 'variant', 'tg-latn' ); + + $this->assertEquals( 'tg-latn', $this->lc->getPreferredVariant() ); + } + + /** + * @covers LanguageConverter::getPreferredVariant + * @covers LanguageConverter::getUserVariant + */ + public function testGetPreferredVariantUserOptionForForeignLanguage() { + global $wgContLang, $wgUser; + + $wgContLang = Language::factory( 'en' ); + $wgUser = new User; + $wgUser->load(); // from 'defaults' + $wgUser->mId = 1; + $wgUser->mDataLoaded = true; + $wgUser->mOptionsLoaded = true; + $wgUser->setOption( 'variant-tg', 'tg-latn' ); + + $this->assertEquals( 'tg-latn', $this->lc->getPreferredVariant() ); + } + + /** + * @covers LanguageConverter::getPreferredVariant + * @covers LanguageConverter::getUserVariant + * @covers LanguageConverter::getURLVariant + */ + public function testGetPreferredVariantHeaderUserVsUrl() { + global $wgContLang, $wgRequest, $wgUser; + + $wgContLang = Language::factory( 'tg-latn' ); + $wgRequest->setVal( 'variant', 'tg' ); + $wgUser = User::newFromId( "admin" ); + $wgUser->setId( 1 ); + $wgUser->mFrom = 'defaults'; + $wgUser->mOptionsLoaded = true; + // The user's data is ignored because the variant is set in the URL. + $wgUser->setOption( 'variant', 'tg-latn' ); + $this->assertEquals( 'tg', $this->lc->getPreferredVariant() ); + } + + /** + * @covers LanguageConverter::getPreferredVariant + */ + public function testGetPreferredVariantDefaultLanguageVariant() { + global $wgDefaultLanguageVariant; + + $wgDefaultLanguageVariant = 'tg-latn'; + $this->assertEquals( 'tg-latn', $this->lc->getPreferredVariant() ); + } + + /** + * @covers LanguageConverter::getPreferredVariant + * @covers LanguageConverter::getURLVariant + */ + public function testGetPreferredVariantDefaultLanguageVsUrlVariant() { + global $wgDefaultLanguageVariant, $wgRequest, $wgContLang; + + $wgContLang = Language::factory( 'tg-latn' ); + $wgDefaultLanguageVariant = 'tg'; + $wgRequest->setVal( 'variant', null ); + $this->assertEquals( 'tg', $this->lc->getPreferredVariant() ); + } +} + +/** + * Test converter (from Tajiki to latin orthography) + */ +class TestConverter extends LanguageConverter { + private $table = array( + 'б' => 'b', + 'в' => 'v', + 'г' => 'g', + ); + + function loadDefaultTables() { + $this->mTables = array( + 'tg-latn' => new ReplacementArray( $this->table ), + 'tg' => new ReplacementArray() + ); + } +} + +class LanguageToTest extends Language { + function __construct() { + parent::__construct(); + $variants = array( 'tg', 'tg-latn' ); + $this->mConverter = new TestConverter( $this, 'tg', $variants ); + } +} diff --git a/tests/phpunit/languages/LanguageCsTest.php b/tests/phpunit/languages/LanguageCsTest.php deleted file mode 100644 index da9e6b88..00000000 --- a/tests/phpunit/languages/LanguageCsTest.php +++ /dev/null @@ -1,41 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static function providePlural() { - 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 deleted file mode 100644 index 07193172..00000000 --- a/tests/phpunit/languages/LanguageCuTest.php +++ /dev/null @@ -1,42 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static function providePlural() { - return array( - array( 'other', 0 ), - array( 'one', 1 ), - array( 'two', 2 ), - array( 'few', 3 ), - array( 'few', 4 ), - array( 'other', 5 ), - array( 'one', 11 ), - array( 'other', 20 ), - array( 'two', 22 ), - array( 'few', 223 ), - array( 'other', 200 ), - ); - } -} diff --git a/tests/phpunit/languages/LanguageCyTest.php b/tests/phpunit/languages/LanguageCyTest.php deleted file mode 100644 index eaf663a8..00000000 --- a/tests/phpunit/languages/LanguageCyTest.php +++ /dev/null @@ -1,43 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static function providePlural() { - 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 deleted file mode 100644 index 94c11bcc..00000000 --- a/tests/phpunit/languages/LanguageDsbTest.php +++ /dev/null @@ -1,41 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static 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 deleted file mode 100644 index 46b65011..00000000 --- a/tests/phpunit/languages/LanguageFrTest.php +++ /dev/null @@ -1,35 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static 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 deleted file mode 100644 index c009f56b..00000000 --- a/tests/phpunit/languages/LanguageGaTest.php +++ /dev/null @@ -1,35 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static function providePlural() { - 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 deleted file mode 100644 index b89b4df9..00000000 --- a/tests/phpunit/languages/LanguageGdTest.php +++ /dev/null @@ -1,53 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - public static function providerPlural() { - return array( - array( 'other', 0 ), - array( 'one', 1 ), - array( 'two', 2 ), - array( 'one', 11 ), - array( 'two', 12 ), - array( 'few', 3 ), - array( 'few', 19 ), - array( 'other', 200 ), - ); - } - - /** - * @dataProvider providerPluralExplicit - * @covers Language::convertPlural - */ - public function testExplicitPlural( $result, $value ) { - $forms = array( 'one', 'two', 'few', 'other', '11=Form11', '12=Form12' ); - $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - public static function providerPluralExplicit() { - return array( - array( 'other', 0 ), - array( 'one', 1 ), - array( 'two', 2 ), - array( 'Form11', 11 ), - array( 'Form12', 12 ), - array( 'few', 3 ), - array( 'few', 19 ), - array( 'other', 200 ), - ); - } -} diff --git a/tests/phpunit/languages/LanguageGvTest.php b/tests/phpunit/languages/LanguageGvTest.php deleted file mode 100644 index fc58022a..00000000 --- a/tests/phpunit/languages/LanguageGvTest.php +++ /dev/null @@ -1,44 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static function providePlural() { - return array( - array( 'few', 0 ), - array( 'one', 1 ), - array( 'two', 2 ), - array( 'other', 3 ), - array( 'few', 20 ), - array( 'one', 21 ), - array( 'two', 22 ), - array( 'other', 23 ), - array( 'other', 50 ), - array( 'few', 60 ), - array( 'other', 80 ), - array( 'few', 100 ) - ); - } -} diff --git a/tests/phpunit/languages/LanguageHeTest.php b/tests/phpunit/languages/LanguageHeTest.php deleted file mode 100644 index c382244f..00000000 --- a/tests/phpunit/languages/LanguageHeTest.php +++ /dev/null @@ -1,132 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider provideThreePluralForms - * @covers Language::convertPlural - */ - public function testThreePluralForms( $result, $value ) { - $forms = array( 'one', 'two', 'other' ); - $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider provideFourPluralForms - * @covers Language::convertPlural - */ - public function testFourPluralForms( $result, $value ) { - $forms = array( '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 array( - 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() { - return array( - 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() { - return array( - 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 - ); - } - - /** - * @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 array( - array( - /* result */'וויקיפדיה', - /* word */'ויקיפדיה', - /* case */'תחילית', - ), - array( - /* result */'וולפגנג', - /* word */'וולפגנג', - /* case */'prefixed', - ), - array( - /* result */'קובץ', - /* word */'הקובץ', - /* case */'תחילית', - ), - array( - /* result */'־Wikipedia', - /* word */'Wikipedia', - /* case */'תחילית', - ), - array( - /* result */'־1995', - /* word */'1995', - /* case */'תחילית', - ), - ); - } -} diff --git a/tests/phpunit/languages/LanguageHiTest.php b/tests/phpunit/languages/LanguageHiTest.php deleted file mode 100644 index f6d2c9e9..00000000 --- a/tests/phpunit/languages/LanguageHiTest.php +++ /dev/null @@ -1,35 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static 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 deleted file mode 100644 index 644c5255..00000000 --- a/tests/phpunit/languages/LanguageHrTest.php +++ /dev/null @@ -1,42 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static function providePlural() { - return array( - array( 'other', 0 ), - array( 'one', 1 ), - array( 'few', 2 ), - array( 'few', 4 ), - array( 'other', 5 ), - array( 'other', 11 ), - array( 'other', 20 ), - array( 'one', 21 ), - array( 'few', 24 ), - array( 'other', 25 ), - array( 'other', 200 ), - ); - } -} diff --git a/tests/phpunit/languages/LanguageHsbTest.php b/tests/phpunit/languages/LanguageHsbTest.php deleted file mode 100644 index f95a43bf..00000000 --- a/tests/phpunit/languages/LanguageHsbTest.php +++ /dev/null @@ -1,41 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static 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/LanguageHuTest.php b/tests/phpunit/languages/LanguageHuTest.php deleted file mode 100644 index ee9197d7..00000000 --- a/tests/phpunit/languages/LanguageHuTest.php +++ /dev/null @@ -1,35 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static function providePlural() { - return array( - array( 'other', 0 ), - array( 'one', 1 ), - array( 'other', 2 ), - array( 'other', 200 ), - ); - } -} diff --git a/tests/phpunit/languages/LanguageHyTest.php b/tests/phpunit/languages/LanguageHyTest.php deleted file mode 100644 index 92e0ef94..00000000 --- a/tests/phpunit/languages/LanguageHyTest.php +++ /dev/null @@ -1,35 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static function providePlural() { - 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 deleted file mode 100644 index 568a3780..00000000 --- a/tests/phpunit/languages/LanguageKshTest.php +++ /dev/null @@ -1,35 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static function providePlural() { - 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 deleted file mode 100644 index 10b3234f..00000000 --- a/tests/phpunit/languages/LanguageLnTest.php +++ /dev/null @@ -1,35 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static 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 deleted file mode 100644 index 30642f62..00000000 --- a/tests/phpunit/languages/LanguageLtTest.php +++ /dev/null @@ -1,63 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static function providePlural() { - 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 ), - ); - } - - /** - * @dataProvider providePluralTwoForms - * @covers Language::convertPlural - */ - public function testOneFewPlural( $result, $value ) { - $forms = array( 'one', 'other' ); - // This fails for 21, but not sure why. - $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - public static function providePluralTwoForms() { - return array( - array( 'one', 1 ), - array( 'other', 2 ), - array( 'other', 15 ), - array( 'other', 20 ), - array( 'one', 21 ), - array( 'other', 22 ), - ); - } -} diff --git a/tests/phpunit/languages/LanguageLvTest.php b/tests/phpunit/languages/LanguageLvTest.php deleted file mode 100644 index 7120cfe3..00000000 --- a/tests/phpunit/languages/LanguageLvTest.php +++ /dev/null @@ -1,44 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static function providePlural() { - return array( - array( 'zero', 0 ), - array( 'one', 1 ), - array( 'zero', 11 ), - array( 'one', 21 ), - array( 'zero', 411 ), - array( 'other', 2 ), - array( 'other', 9 ), - array( 'zero', 12 ), - array( 'other', 12.345 ), - array( 'zero', 20 ), - array( 'other', 22 ), - array( 'one', 31 ), - array( 'zero', 200 ), - ); - } -} diff --git a/tests/phpunit/languages/LanguageMgTest.php b/tests/phpunit/languages/LanguageMgTest.php deleted file mode 100644 index 65e8fd7b..00000000 --- a/tests/phpunit/languages/LanguageMgTest.php +++ /dev/null @@ -1,36 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static 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 deleted file mode 100644 index ed155263..00000000 --- a/tests/phpunit/languages/LanguageMkTest.php +++ /dev/null @@ -1,40 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static function providePlural() { - return array( - array( 'other', 0 ), - array( 'one', 1 ), - array( 'one', 11 ), - array( 'one', 21 ), - array( 'one', 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 deleted file mode 100644 index 4fa45ce3..00000000 --- a/tests/phpunit/languages/LanguageMlTest.php +++ /dev/null @@ -1,38 +0,0 @@ -assertEquals( $result, $this->getLang()->formatNum( $value ) ); - } - - public static 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 deleted file mode 100644 index e0e54ca8..00000000 --- a/tests/phpunit/languages/LanguageMoTest.php +++ /dev/null @@ -1,45 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static function providePlural() { - 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 deleted file mode 100644 index 96d2bc92..00000000 --- a/tests/phpunit/languages/LanguageMtTest.php +++ /dev/null @@ -1,77 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static function providePlural() { - 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 providePluralTwoForms - * @covers Language::convertPlural - */ - public function testPluralTwoForms( $result, $value ) { - $forms = array( 'one', 'other' ); - $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - public static function providePluralTwoForms() { - return array( - array( 'other', 0 ), - array( 'one', 1 ), - array( 'other', 2 ), - array( 'other', 10 ), - array( 'other', 11 ), - array( 'other', 19 ), - array( 'other', 20 ), - array( 'other', 99 ), - array( 'other', 100 ), - array( 'other', 101 ), - array( 'other', 102 ), - array( 'other', 110 ), - array( 'other', 111 ), - array( 'other', 119 ), - array( 'other', 120 ), - array( 'other', 201 ), - ); - } -} diff --git a/tests/phpunit/languages/LanguageNlTest.php b/tests/phpunit/languages/LanguageNlTest.php deleted file mode 100644 index 26bd691a..00000000 --- a/tests/phpunit/languages/LanguageNlTest.php +++ /dev/null @@ -1,24 +0,0 @@ -assertEquals( '1.234.567', $this->getLang()->formatNum( '1234567' ) ); - $this->assertEquals( '12.345', $this->getLang()->formatNum( '12345' ) ); - $this->assertEquals( '1', $this->getLang()->formatNum( '1' ) ); - $this->assertEquals( '123', $this->getLang()->formatNum( '123' ) ); - $this->assertEquals( '1.234', $this->getLang()->formatNum( '1234' ) ); - $this->assertEquals( '12.345,56', $this->getLang()->formatNum( '12345.56' ) ); - $this->assertEquals( ',1234556', $this->getLang()->formatNum( '.1234556' ) ); - } -} diff --git a/tests/phpunit/languages/LanguageNsoTest.php b/tests/phpunit/languages/LanguageNsoTest.php deleted file mode 100644 index 18efd736..00000000 --- a/tests/phpunit/languages/LanguageNsoTest.php +++ /dev/null @@ -1,34 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static function providePlural() { - return array( - array( 'one', 0 ), - array( 'one', 1 ), - array( 'other', 2 ), - ); - } -} diff --git a/tests/phpunit/languages/LanguagePlTest.php b/tests/phpunit/languages/LanguagePlTest.php deleted file mode 100644 index d180037b..00000000 --- a/tests/phpunit/languages/LanguagePlTest.php +++ /dev/null @@ -1,77 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static function providePlural() { - 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 providePluralTwoForms - * @covers Language::convertPlural - */ - public function testPluralTwoForms( $result, $value ) { - $forms = array( 'one', 'other' ); - $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - public static function providePluralTwoForms() { - return array( - array( 'other', 0 ), - array( 'one', 1 ), - array( 'other', 2 ), - array( 'other', 3 ), - array( 'other', 4 ), - array( 'other', 5 ), - array( 'other', 9 ), - array( 'other', 10 ), - array( 'other', 11 ), - array( 'other', 21 ), - array( 'other', 22 ), - array( 'other', 23 ), - array( 'other', 24 ), - array( 'other', 25 ), - array( 'other', 200 ), - array( 'other', 201 ), - ); - } -} diff --git a/tests/phpunit/languages/LanguageRoTest.php b/tests/phpunit/languages/LanguageRoTest.php deleted file mode 100644 index ae7816bc..00000000 --- a/tests/phpunit/languages/LanguageRoTest.php +++ /dev/null @@ -1,45 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static function providePlural() { - 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 deleted file mode 100644 index f64fc722..00000000 --- a/tests/phpunit/languages/LanguageRuTest.php +++ /dev/null @@ -1,115 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * Test explicit plural forms - n=FormN forms - * @covers Language::convertPlural - */ - public function testExplicitPlural() { - $forms = array( 'one', 'many', 'other', '12=dozen' ); - $this->assertEquals( 'dozen', $this->getLang()->convertPlural( 12, $forms ) ); - $forms = array( 'one', 'many', '100=hundred', 'other', '12=dozen' ); - $this->assertEquals( 'hundred', $this->getLang()->convertPlural( 100, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static function providePlural() { - return array( - array( 'one', 1 ), - array( 'many', 11 ), - array( 'one', 91 ), - array( 'one', 121 ), - array( 'other', 2 ), - array( 'other', 3 ), - array( 'other', 4 ), - array( 'other', 334 ), - array( 'many', 5 ), - array( 'many', 15 ), - array( 'many', 120 ), - ); - } - - /** - * @dataProvider providePluralTwoForms - * @covers Language::convertPlural - */ - public function testPluralTwoForms( $result, $value ) { - $forms = array( '1=one', 'other' ); - $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - public static function providePluralTwoForms() { - return array( - array( 'one', 1 ), - array( 'other', 11 ), - array( 'other', 91 ), - array( 'other', 121 ), - ); - } - - /** - * @dataProvider providerGrammar - * @covers Language::convertGrammar - */ - public function testGrammar( $result, $word, $case ) { - $this->assertEquals( $result, $this->getLang()->convertGrammar( $word, $case ) ); - } - - public static function providerGrammar() { - return array( - array( - 'Википедии', - 'Википедия', - 'genitive', - ), - array( - 'Викитеки', - 'Викитека', - 'genitive', - ), - array( - 'Викитеке', - 'Викитека', - 'prepositional', - ), - array( - 'Викисклада', - 'Викисклад', - 'genitive', - ), - array( - 'Викискладе', - 'Викисклад', - 'prepositional', - ), - array( - 'Викиданных', - 'Викиданные', - 'prepositional', - ), - ); - } -} diff --git a/tests/phpunit/languages/LanguageSeTest.php b/tests/phpunit/languages/LanguageSeTest.php deleted file mode 100644 index 533aa2bc..00000000 --- a/tests/phpunit/languages/LanguageSeTest.php +++ /dev/null @@ -1,53 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static function providePlural() { - return array( - array( 'other', 0 ), - array( 'one', 1 ), - array( 'two', 2 ), - array( 'other', 3 ), - ); - } - - /** - * @dataProvider providePluralTwoForms - * @covers Language::convertPlural - */ - public function testPluralTwoForms( $result, $value ) { - $forms = array( 'one', 'other' ); - $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - public static function providePluralTwoForms() { - 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 deleted file mode 100644 index fa49a4dd..00000000 --- a/tests/phpunit/languages/LanguageSgsTest.php +++ /dev/null @@ -1,71 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providePluralAllForms - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static function providePluralAllForms() { - return array( - array( 'few', 0 ), - array( 'one', 1 ), - array( 'two', 2 ), - array( 'other', 3 ), - array( 'few', 10 ), - array( 'few', 11 ), - array( 'few', 12 ), - array( 'few', 19 ), - array( 'other', 20 ), - array( 'few', 100 ), - array( 'one', 101 ), - array( 'few', 111 ), - array( 'few', 112 ), - ); - } - - /** - * @dataProvider providePluralTwoForms - * @covers Language::convertPlural - */ - public function testPluralTwoForms( $result, $value ) { - $forms = array( 'one', 'other' ); - $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - public static 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 deleted file mode 100644 index 1b390872..00000000 --- a/tests/phpunit/languages/LanguageShTest.php +++ /dev/null @@ -1,42 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static function providePlural() { - return array( - array( 'other', 0 ), - array( 'one', 1 ), - array( 'few', 2 ), - array( 'few', 4 ), - array( 'other', 5 ), - array( 'other', 10 ), - array( 'other', 11 ), - array( 'other', 12 ), - array( 'one', 101 ), - array( 'few', 102 ), - array( 'other', 111 ), - ); - } -} diff --git a/tests/phpunit/languages/LanguageSkTest.php b/tests/phpunit/languages/LanguageSkTest.php deleted file mode 100644 index cb8a13b8..00000000 --- a/tests/phpunit/languages/LanguageSkTest.php +++ /dev/null @@ -1,42 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static function providePlural() { - 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 deleted file mode 100644 index 9783dd80..00000000 --- a/tests/phpunit/languages/LanguageSlTest.php +++ /dev/null @@ -1,44 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providerPlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static function providerPlural() { - return array( - array( 'other', 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 deleted file mode 100644 index 95cb333c..00000000 --- a/tests/phpunit/languages/LanguageSmaTest.php +++ /dev/null @@ -1,53 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static function providePlural() { - return array( - array( 'other', 0 ), - array( 'one', 1 ), - array( 'two', 2 ), - array( 'other', 3 ), - ); - } - - /** - * @dataProvider providePluralTwoForms - * @covers Language::convertPlural - */ - public function testPluralTwoForms( $result, $value ) { - $forms = array( 'one', 'other' ); - $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - public static function providePluralTwoForms() { - 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 deleted file mode 100644 index bfb199f3..00000000 --- a/tests/phpunit/languages/LanguageSrTest.php +++ /dev/null @@ -1,249 +0,0 @@ - - * @copyright Copyright © 2011, Antoine Musso - * @file - * - * @todo methods in test class should be tidied: - * - Should be split into separate test methods and data providers - * - Tests for LanguageConverter and Language should probably be separate.. - */ - -/** Tests for MediaWiki languages/LanguageSr.php */ -class LanguageSrTest extends LanguageClassesTestCase { - /** - * @covers LanguageConverter::convertTo - */ - public function testEasyConversions() { - $this->assertCyrillic( - 'шђчћжШЂЧЋЖ', - 'Cyrillic guessing characters' - ); - $this->assertLatin( - 'šđč枊ĐČĆŽ', - 'Latin guessing characters' - ); - } - - /** - * @covers LanguageConverter::convertTo - */ - public function testMixedConversions() { - $this->assertCyrillic( - 'шђчћжШЂЧЋЖ - šđčćž', - 'Mostly cyrillic characters' - ); - $this->assertLatin( - 'šđč枊ĐČĆŽ - шђчћж', - 'Mostly latin characters' - ); - } - - /** - * @covers LanguageConverter::convertTo - */ - public function testSameAmountOfLatinAndCyrillicGetConverted() { - $this->assertConverted( - '4 latin: šđčć | 4 cyrillic: шђчћ', - 'sr-ec' - ); - $this->assertConverted( - '4 latin: šđčć | 4 cyrillic: шђчћ', - 'sr-el' - ); - } - - /** - * @author Nikola Smolenski - * @covers LanguageConverter::convertTo - */ - public function testConversionToCyrillic() { - //A simple convertion of Latin to Cyrillic - $this->assertEquals( 'абвг', - $this->convertToCyrillic( 'abvg' ) - ); - //Same as above, but assert that -{}-s must be removed and not converted - $this->assertEquals( 'ljабnjвгdž', - $this->convertToCyrillic( '-{lj}-ab-{nj}-vg-{dž}-' ) - ); - //A simple convertion of Cyrillic to Cyrillic - $this->assertEquals( 'абвг', - $this->convertToCyrillic( 'абвг' ) - ); - //Same as above, but assert that -{}-s must be removed and not converted - $this->assertEquals( 'ljабnjвгdž', - $this->convertToCyrillic( '-{lj}-аб-{nj}-вг-{dž}-' ) - ); - //This text has some Latin, but is recognized as Cyrillic, so it should not be converted - $this->assertEquals( 'abvgшђжчћ', - $this->convertToCyrillic( 'abvgшђжчћ' ) - ); - //Same as above, but assert that -{}-s must be removed - $this->assertEquals( 'љabvgњшђжчћџ', - $this->convertToCyrillic( '-{љ}-abvg-{њ}-шђжчћ-{џ}-' ) - ); - //This text has some Cyrillic, but is recognized as Latin, so it should be converted - $this->assertEquals( 'абвгшђжчћ', - $this->convertToCyrillic( 'абвгšđžčć' ) - ); - //Same as above, but assert that -{}-s must be removed and not converted - $this->assertEquals( 'ljабвгnjшђжчћdž', - $this->convertToCyrillic( '-{lj}-абвг-{nj}-šđžčć-{dž}-' ) - ); - // Roman numerals are not converted - $this->assertEquals( 'а I б II в III г IV шђжчћ', - $this->convertToCyrillic( 'a I b II v III g IV šđžčć' ) - ); - } - - /** - * @covers LanguageConverter::convertTo - */ - public function testConversionToLatin() { - //A simple convertion of Latin to Latin - $this->assertEquals( 'abcd', - $this->convertToLatin( 'abcd' ) - ); - //A simple convertion of Cyrillic to Latin - $this->assertEquals( 'abcd', - $this->convertToLatin( 'абцд' ) - ); - //This text has some Latin, but is recognized as Cyrillic, so it should be converted - $this->assertEquals( 'abcdšđžčć', - $this->convertToLatin( 'abcdшђжчћ' ) - ); - //This text has some Cyrillic, but is recognized as Latin, so it should not be converted - $this->assertEquals( 'абцдšđžčć', - $this->convertToLatin( 'абцдšđžčć' ) - ); - } - - /** - * @dataProvider providePlural - * @covers Language::convertPlural - */ - public function testPlural( $result, $value ) { - $forms = array( 'one', 'few', 'other' ); - $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static function providePlural() { - return array( - array( 'one', 1 ), - array( 'other', 11 ), - array( 'one', 91 ), - array( 'one', 121 ), - array( 'few', 2 ), - array( 'few', 3 ), - array( 'few', 4 ), - array( 'few', 334 ), - array( 'other', 5 ), - array( 'other', 15 ), - array( 'other', 120 ), - ); - } - - /** - * @dataProvider providePluralTwoForms - * @covers Language::convertPlural - */ - public function testPluralTwoForms( $result, $value ) { - $forms = array( 'one', 'other' ); - $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - public static function providePluralTwoForms() { - return array( - array( 'one', 1 ), - array( 'other', 11 ), - array( 'other', 4 ), - array( 'one', 91 ), - array( 'one', 121 ), - ); - } - - ##### HELPERS ##################################################### - /** - *Wrapper to verify text stay the same after applying conversion - * @param string $text Text to convert - * @param string $variant Language variant 'sr-ec' or 'sr-el' - * @param string $msg Optional message - */ - protected 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 string $text Text to convert - * @param string $variant Language variant 'sr-ec' or 'sr-el' - * @param string $msg Optional message - */ - protected 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. - * @param string $text Text to convert - * @param string $msg Optional message - */ - protected 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. - * @param string $text Text to convert - * @param string $msg Optional message - */ - protected function assertLatin( $text, $msg = '' ) { - $this->assertUnConverted( $text, 'sr-el', $msg ); - $this->assertConverted( $text, 'sr-ec', $msg ); - } - - /** Wrapper for converter::convertTo() method*/ - protected function convertTo( $text, $variant ) { - return $this->getLang() - ->mConverter - ->convertTo( - $text, $variant - ); - } - - protected function convertToCyrillic( $text ) { - return $this->convertTo( $text, 'sr-ec' ); - } - - protected function convertToLatin( $text ) { - return $this->convertTo( $text, 'sr-el' ); - } -} diff --git a/tests/phpunit/languages/LanguageTiTest.php b/tests/phpunit/languages/LanguageTiTest.php deleted file mode 100644 index e225af97..00000000 --- a/tests/phpunit/languages/LanguageTiTest.php +++ /dev/null @@ -1,34 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static function providePlural() { - return array( - array( 'one', 0 ), - array( 'one', 1 ), - array( 'other', 2 ), - ); - } -} diff --git a/tests/phpunit/languages/LanguageTlTest.php b/tests/phpunit/languages/LanguageTlTest.php deleted file mode 100644 index 7ac51c69..00000000 --- a/tests/phpunit/languages/LanguageTlTest.php +++ /dev/null @@ -1,34 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static function providePlural() { - return array( - array( 'one', 0 ), - array( 'one', 1 ), - array( 'other', 2 ), - ); - } -} diff --git a/tests/phpunit/languages/LanguageTrTest.php b/tests/phpunit/languages/LanguageTrTest.php deleted file mode 100644 index 2c9905f7..00000000 --- a/tests/phpunit/languages/LanguageTrTest.php +++ /dev/null @@ -1,61 +0,0 @@ -getLang()->ucfirst( $input ); - } elseif ( $func == 'lcfirst' ) { - $res = $this->getLang()->lcfirst( $input ); - } else { - throw new MWException( __METHOD__ . " given an invalid function name '$func'" ); - } - - $msg = "Converting $inputCase case '$input' with $func should give '$expected'"; - - $this->assertEquals( $expected, $res, $msg ); - } - - public static function provideDottedAndDotlessI() { - return array( - # function, input, input case, expected - # Case changed: - array( 'ucfirst', 'ı', 'lower', 'I' ), - array( 'ucfirst', 'i', 'lower', 'İ' ), - array( 'lcfirst', 'I', 'upper', 'ı' ), - array( 'lcfirst', 'İ', 'upper', 'i' ), - - # Already using the correct case - array( 'ucfirst', 'I', 'upper', 'I' ), - array( 'ucfirst', 'İ', 'upper', 'İ' ), - array( 'lcfirst', 'ı', 'lower', 'ı' ), - array( 'lcfirst', 'i', 'lower', 'i' ), - - # A real example taken from bug 28040 using - # http://tr.wikipedia.org/wiki/%C4%B0Phone - array( 'lcfirst', 'iPhone', 'lower', 'iPhone' ), - - # next case is valid in Turkish but are different words if we - # consider IPhone is English! - array( 'lcfirst', 'IPhone', 'upper', 'ıPhone' ), - - ); - } -} diff --git a/tests/phpunit/languages/LanguageUkTest.php b/tests/phpunit/languages/LanguageUkTest.php deleted file mode 100644 index 9051bcff..00000000 --- a/tests/phpunit/languages/LanguageUkTest.php +++ /dev/null @@ -1,72 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * Test explicit plural forms - n=FormN forms - * @covers Language::convertPlural - */ - public function testExplicitPlural() { - $forms = array( 'one', 'few', 'many', 'other', '12=dozen' ); - $this->assertEquals( 'dozen', $this->getLang()->convertPlural( 12, $forms ) ); - $forms = array( 'one', 'few', 'many', '100=hundred', 'other', '12=dozen' ); - $this->assertEquals( 'hundred', $this->getLang()->convertPlural( 100, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static 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 ), - ); - } - - /** - * @dataProvider providePluralTwoForms - * @covers Language::convertPlural - */ - public function testPluralTwoForms( $result, $value ) { - $forms = array( '1=one', 'other' ); - $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - public static function providePluralTwoForms() { - return array( - array( 'one', 1 ), - array( 'other', 11 ), - array( 'other', 91 ), - array( 'other', 121 ), - ); - } -} diff --git a/tests/phpunit/languages/LanguageUzTest.php b/tests/phpunit/languages/LanguageUzTest.php deleted file mode 100644 index 4881103f..00000000 --- a/tests/phpunit/languages/LanguageUzTest.php +++ /dev/null @@ -1,124 +0,0 @@ - - * @copyright Copyright © 2012, Robin Pepermans - * @copyright Copyright © 2011, Antoine Musso - * @file - * - * @todo methods in test class should be tidied: - * - Should be split into separate test methods and data providers - * - Tests for LanguageConverter and Language should probably be separate.. - */ - -/** Tests for MediaWiki languages/LanguageUz.php */ -class LanguageUzTest extends LanguageClassesTestCase { - - /** - * @author Nikola Smolenski - * @covers LanguageConverter::convertTo - */ - public function testConversionToCyrillic() { - // A convertion of Latin to Cyrillic - $this->assertEquals( 'абвгғ', - $this->convertToCyrillic( 'abvggʻ' ) - ); - // Same as above, but assert that -{}-s must be removed and not converted - $this->assertEquals( 'ljабnjвгўоdb', - $this->convertToCyrillic( '-{lj}-ab-{nj}-vgoʻo-{db}-' ) - ); - // A simple convertion of Cyrillic to Cyrillic - $this->assertEquals( 'абвг', - $this->convertToCyrillic( 'абвг' ) - ); - // Same as above, but assert that -{}-s must be removed and not converted - $this->assertEquals( 'ljабnjвгdaž', - $this->convertToCyrillic( '-{lj}-аб-{nj}-вг-{da}-ž' ) - ); - } - - /** - * @covers LanguageConverter::convertTo - */ - public function testConversionToLatin() { - // A simple convertion of Latin to Latin - $this->assertEquals( 'abdef', - $this->convertToLatin( 'abdef' ) - ); - // A convertion of Cyrillic to Latin - $this->assertEquals( 'gʻabtsdOʻQyo', - $this->convertToLatin( 'ғабцдЎҚё' ) - ); - } - - ##### HELPERS ##################################################### - /** - * Wrapper to verify text stay the same after applying conversion - * @param string $text Text to convert - * @param string $variant Language variant 'uz-cyrl' or 'uz-latn' - * @param string $msg Optional message - */ - protected 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 string $text Text to convert - * @param string $variant Language variant 'uz-cyrl' or 'uz-latn' - * @param string $msg Optional message - */ - protected 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. - * @param string $text Text to convert - * @param string $msg Optional message - */ - protected function assertCyrillic( $text, $msg = '' ) { - $this->assertUnConverted( $text, 'uz-cyrl', $msg ); - $this->assertConverted( $text, 'uz-latn', $msg ); - } - - /** - * Verifiy the given Latin text is not converted when using - * using the Latin variant and converted to Cyrillic when using - * the Cyrillic variant. - * @param string $text Text to convert - * @param string $msg Optional message - */ - protected function assertLatin( $text, $msg = '' ) { - $this->assertUnConverted( $text, 'uz-latn', $msg ); - $this->assertConverted( $text, 'uz-cyrl', $msg ); - } - - /** Wrapper for converter::convertTo() method*/ - protected function convertTo( $text, $variant ) { - return $this->getLang()->mConverter->convertTo( $text, $variant ); - } - - protected function convertToCyrillic( $text ) { - return $this->convertTo( $text, 'uz-cyrl' ); - } - - protected function convertToLatin( $text ) { - return $this->convertTo( $text, 'uz-latn' ); - } -} diff --git a/tests/phpunit/languages/LanguageWaTest.php b/tests/phpunit/languages/LanguageWaTest.php deleted file mode 100644 index d05196c0..00000000 --- a/tests/phpunit/languages/LanguageWaTest.php +++ /dev/null @@ -1,34 +0,0 @@ -assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); - } - - /** - * @dataProvider providePlural - * @covers Language::getPluralRuleType - */ - public function testGetPluralRuleType( $result, $value ) { - $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); - } - - public static function providePlural() { - return array( - array( 'one', 0 ), - array( 'one', 1 ), - array( 'other', 2 ), - ); - } -} diff --git a/tests/phpunit/languages/SpecialPageAliasTest.php b/tests/phpunit/languages/SpecialPageAliasTest.php index f6d6bc96..a6d9d270 100644 --- a/tests/phpunit/languages/SpecialPageAliasTest.php +++ b/tests/phpunit/languages/SpecialPageAliasTest.php @@ -8,7 +8,6 @@ * @group SystemTest * @group medium * - * @licence GNU GPL v2+ * @author Katie Filbert < aude.wiki@gmail.com > */ class SpecialPageAliasTest extends MediaWikiTestCase { diff --git a/tests/phpunit/languages/classes/LanguageAmTest.php b/tests/phpunit/languages/classes/LanguageAmTest.php new file mode 100644 index 00000000..a644f5e0 --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageAmTest.php @@ -0,0 +1,35 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static function providePlural() { + return array( + array( 'one', 0 ), + array( 'one', 1 ), + array( 'other', 2 ), + array( 'other', 200 ), + ); + } +} diff --git a/tests/phpunit/languages/classes/LanguageArTest.php b/tests/phpunit/languages/classes/LanguageArTest.php new file mode 100644 index 00000000..7b48f236 --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageArTest.php @@ -0,0 +1,87 @@ +assertEquals( '١٬٢٣٤٬٥٦٧', $this->getLang()->formatNum( '1234567' ) ); + $this->assertEquals( '-١٢٫٨٩', $this->getLang()->formatNum( -12.89 ) ); + } + + /** + * Mostly to test the raw ascii feature. + * @dataProvider providerSprintfDate + * @covers Language::sprintfDate + */ + public function testSprintfDate( $format, $date, $expected ) { + $this->assertEquals( $expected, $this->getLang()->sprintfDate( $format, $date ) ); + } + + public static 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 + * @covers Language::convertPlural + */ + public function testPlural( $result, $value ) { + $forms = array( 'zero', 'one', 'two', 'few', 'many', 'other' ); + $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static 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/classes/LanguageArqTest.php b/tests/phpunit/languages/classes/LanguageArqTest.php new file mode 100644 index 00000000..3fa56d78 --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageArqTest.php @@ -0,0 +1,26 @@ +assertEquals( $result, $this->getLang()->formatNum( $value ) ); + } + + public static function provideNumber() { + return array( + array( '1.234.567', '1234567'), + array( '-12,89', -12.89 ), + ); + } + +} diff --git a/tests/phpunit/languages/classes/LanguageBeTest.php b/tests/phpunit/languages/classes/LanguageBeTest.php new file mode 100644 index 00000000..7bd586af --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageBeTest.php @@ -0,0 +1,42 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static 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/classes/LanguageBe_taraskTest.php b/tests/phpunit/languages/classes/LanguageBe_taraskTest.php new file mode 100644 index 00000000..4dd5cdd7 --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageBe_taraskTest.php @@ -0,0 +1,97 @@ +assertEquals( 'be-tarask', + $this->getLang()->getCode() + ); + } + + /** + * @see bug 23156 & r64981 + * @covers Language::commafy + */ + public function testSearchRightSingleQuotationMarkAsApostroph() { + $this->assertEquals( + "'", + $this->getLang()->normalizeForSearch( '’' ), + 'bug 23156: U+2019 conversion to U+0027' + ); + } + + /** + * @see bug 23156 & r64981 + * @covers Language::commafy + */ + public function testCommafy() { + $this->assertEquals( '1,234,567', $this->getLang()->commafy( '1234567' ) ); + $this->assertEquals( '12,345', $this->getLang()->commafy( '12345' ) ); + } + + /** + * @see bug 23156 & r64981 + * @covers Language::commafy + */ + public function testDoesNotCommafyFourDigitsNumber() { + $this->assertEquals( '1234', $this->getLang()->commafy( '1234' ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::convertPlural + */ + public function testPlural( $result, $value ) { + $forms = array( 'one', 'few', 'many', 'other' ); + $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static 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 ), + ); + } + + /** + * @dataProvider providePluralTwoForms + * @covers Language::convertPlural + */ + public function testPluralTwoForms( $result, $value ) { + $forms = array( '1=one', 'other' ); + $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + public static function providePluralTwoForms() { + return array( + array( 'other', 0 ), + array( 'one', 1 ), + array( 'other', 11 ), + array( 'other', 91 ), + array( 'other', 121 ), + ); + } +} diff --git a/tests/phpunit/languages/classes/LanguageBhoTest.php b/tests/phpunit/languages/classes/LanguageBhoTest.php new file mode 100644 index 00000000..187bfbbc --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageBhoTest.php @@ -0,0 +1,35 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static function providePlural() { + return array( + array( 'one', 0 ), + array( 'one', 1 ), + array( 'other', 2 ), + array( 'other', 200 ), + ); + } +} diff --git a/tests/phpunit/languages/classes/LanguageBsTest.php b/tests/phpunit/languages/classes/LanguageBsTest.php new file mode 100644 index 00000000..7aca2ab1 --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageBsTest.php @@ -0,0 +1,42 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static function providePlural() { + return array( + array( 'other', 0 ), + array( 'one', 1 ), + array( 'few', 2 ), + array( 'few', 4 ), + array( 'other', 5 ), + array( 'other', 11 ), + array( 'other', 20 ), + array( 'one', 21 ), + array( 'few', 24 ), + array( 'other', 25 ), + array( 'other', 200 ), + ); + } +} diff --git a/tests/phpunit/languages/classes/LanguageCsTest.php b/tests/phpunit/languages/classes/LanguageCsTest.php new file mode 100644 index 00000000..da9e6b88 --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageCsTest.php @@ -0,0 +1,41 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static function providePlural() { + 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/classes/LanguageCuTest.php b/tests/phpunit/languages/classes/LanguageCuTest.php new file mode 100644 index 00000000..07193172 --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageCuTest.php @@ -0,0 +1,42 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static function providePlural() { + return array( + array( 'other', 0 ), + array( 'one', 1 ), + array( 'two', 2 ), + array( 'few', 3 ), + array( 'few', 4 ), + array( 'other', 5 ), + array( 'one', 11 ), + array( 'other', 20 ), + array( 'two', 22 ), + array( 'few', 223 ), + array( 'other', 200 ), + ); + } +} diff --git a/tests/phpunit/languages/classes/LanguageCyTest.php b/tests/phpunit/languages/classes/LanguageCyTest.php new file mode 100644 index 00000000..eaf663a8 --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageCyTest.php @@ -0,0 +1,43 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static function providePlural() { + 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/classes/LanguageDsbTest.php b/tests/phpunit/languages/classes/LanguageDsbTest.php new file mode 100644 index 00000000..94c11bcc --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageDsbTest.php @@ -0,0 +1,41 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static 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/classes/LanguageFrTest.php b/tests/phpunit/languages/classes/LanguageFrTest.php new file mode 100644 index 00000000..46b65011 --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageFrTest.php @@ -0,0 +1,35 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static function providePlural() { + return array( + array( 'one', 0 ), + array( 'one', 1 ), + array( 'other', 2 ), + array( 'other', 200 ), + ); + } +} diff --git a/tests/phpunit/languages/classes/LanguageGaTest.php b/tests/phpunit/languages/classes/LanguageGaTest.php new file mode 100644 index 00000000..c009f56b --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageGaTest.php @@ -0,0 +1,35 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static function providePlural() { + return array( + array( 'other', 0 ), + array( 'one', 1 ), + array( 'two', 2 ), + array( 'other', 200 ), + ); + } +} diff --git a/tests/phpunit/languages/classes/LanguageGdTest.php b/tests/phpunit/languages/classes/LanguageGdTest.php new file mode 100644 index 00000000..b89b4df9 --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageGdTest.php @@ -0,0 +1,53 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + public static function providerPlural() { + return array( + array( 'other', 0 ), + array( 'one', 1 ), + array( 'two', 2 ), + array( 'one', 11 ), + array( 'two', 12 ), + array( 'few', 3 ), + array( 'few', 19 ), + array( 'other', 200 ), + ); + } + + /** + * @dataProvider providerPluralExplicit + * @covers Language::convertPlural + */ + public function testExplicitPlural( $result, $value ) { + $forms = array( 'one', 'two', 'few', 'other', '11=Form11', '12=Form12' ); + $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + public static function providerPluralExplicit() { + return array( + array( 'other', 0 ), + array( 'one', 1 ), + array( 'two', 2 ), + array( 'Form11', 11 ), + array( 'Form12', 12 ), + array( 'few', 3 ), + array( 'few', 19 ), + array( 'other', 200 ), + ); + } +} diff --git a/tests/phpunit/languages/classes/LanguageGvTest.php b/tests/phpunit/languages/classes/LanguageGvTest.php new file mode 100644 index 00000000..e6a0cf07 --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageGvTest.php @@ -0,0 +1,44 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static function providePlural() { + return array( + array( 'few', 0 ), + array( 'one', 1 ), + array( 'two', 2 ), + array( 'other', 3 ), + array( 'few', 20 ), + array( 'one', 21 ), + array( 'two', 22 ), + array( 'other', 23 ), + array( 'other', 50 ), + array( 'few', 60 ), + array( 'few', 80 ), + array( 'few', 100 ) + ); + } +} diff --git a/tests/phpunit/languages/classes/LanguageHeTest.php b/tests/phpunit/languages/classes/LanguageHeTest.php new file mode 100644 index 00000000..c382244f --- /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 = array( 'one', 'two', 'other' ); + $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider provideFourPluralForms + * @covers Language::convertPlural + */ + public function testFourPluralForms( $result, $value ) { + $forms = array( '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 array( + 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() { + return array( + 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() { + return array( + 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 + ); + } + + /** + * @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 array( + array( + /* result */'וויקיפדיה', + /* word */'ויקיפדיה', + /* case */'תחילית', + ), + array( + /* result */'וולפגנג', + /* word */'וולפגנג', + /* case */'prefixed', + ), + array( + /* result */'קובץ', + /* word */'הקובץ', + /* case */'תחילית', + ), + array( + /* result */'־Wikipedia', + /* word */'Wikipedia', + /* case */'תחילית', + ), + array( + /* result */'־1995', + /* word */'1995', + /* case */'תחילית', + ), + ); + } +} diff --git a/tests/phpunit/languages/classes/LanguageHiTest.php b/tests/phpunit/languages/classes/LanguageHiTest.php new file mode 100644 index 00000000..f6d2c9e9 --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageHiTest.php @@ -0,0 +1,35 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static function providePlural() { + return array( + array( 'one', 0 ), + array( 'one', 1 ), + array( 'other', 2 ), + array( 'other', 200 ), + ); + } +} diff --git a/tests/phpunit/languages/classes/LanguageHrTest.php b/tests/phpunit/languages/classes/LanguageHrTest.php new file mode 100644 index 00000000..644c5255 --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageHrTest.php @@ -0,0 +1,42 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static function providePlural() { + return array( + array( 'other', 0 ), + array( 'one', 1 ), + array( 'few', 2 ), + array( 'few', 4 ), + array( 'other', 5 ), + array( 'other', 11 ), + array( 'other', 20 ), + array( 'one', 21 ), + array( 'few', 24 ), + array( 'other', 25 ), + array( 'other', 200 ), + ); + } +} diff --git a/tests/phpunit/languages/classes/LanguageHsbTest.php b/tests/phpunit/languages/classes/LanguageHsbTest.php new file mode 100644 index 00000000..f95a43bf --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageHsbTest.php @@ -0,0 +1,41 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static 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/classes/LanguageHuTest.php b/tests/phpunit/languages/classes/LanguageHuTest.php new file mode 100644 index 00000000..ee9197d7 --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageHuTest.php @@ -0,0 +1,35 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static function providePlural() { + return array( + array( 'other', 0 ), + array( 'one', 1 ), + array( 'other', 2 ), + array( 'other', 200 ), + ); + } +} diff --git a/tests/phpunit/languages/classes/LanguageHyTest.php b/tests/phpunit/languages/classes/LanguageHyTest.php new file mode 100644 index 00000000..92e0ef94 --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageHyTest.php @@ -0,0 +1,35 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static function providePlural() { + return array( + array( 'one', 0 ), + array( 'one', 1 ), + array( 'other', 2 ), + array( 'other', 200 ), + ); + } +} diff --git a/tests/phpunit/languages/classes/LanguageKshTest.php b/tests/phpunit/languages/classes/LanguageKshTest.php new file mode 100644 index 00000000..568a3780 --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageKshTest.php @@ -0,0 +1,35 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static function providePlural() { + return array( + array( 'zero', 0 ), + array( 'one', 1 ), + array( 'other', 2 ), + array( 'other', 200 ), + ); + } +} diff --git a/tests/phpunit/languages/classes/LanguageLnTest.php b/tests/phpunit/languages/classes/LanguageLnTest.php new file mode 100644 index 00000000..10b3234f --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageLnTest.php @@ -0,0 +1,35 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static function providePlural() { + return array( + array( 'one', 0 ), + array( 'one', 1 ), + array( 'other', 2 ), + array( 'other', 200 ), + ); + } +} diff --git a/tests/phpunit/languages/classes/LanguageLtTest.php b/tests/phpunit/languages/classes/LanguageLtTest.php new file mode 100644 index 00000000..30642f62 --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageLtTest.php @@ -0,0 +1,63 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static function providePlural() { + 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 ), + ); + } + + /** + * @dataProvider providePluralTwoForms + * @covers Language::convertPlural + */ + public function testOneFewPlural( $result, $value ) { + $forms = array( 'one', 'other' ); + // This fails for 21, but not sure why. + $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + public static function providePluralTwoForms() { + return array( + array( 'one', 1 ), + array( 'other', 2 ), + array( 'other', 15 ), + array( 'other', 20 ), + array( 'one', 21 ), + array( 'other', 22 ), + ); + } +} diff --git a/tests/phpunit/languages/classes/LanguageLvTest.php b/tests/phpunit/languages/classes/LanguageLvTest.php new file mode 100644 index 00000000..7120cfe3 --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageLvTest.php @@ -0,0 +1,44 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static function providePlural() { + return array( + array( 'zero', 0 ), + array( 'one', 1 ), + array( 'zero', 11 ), + array( 'one', 21 ), + array( 'zero', 411 ), + array( 'other', 2 ), + array( 'other', 9 ), + array( 'zero', 12 ), + array( 'other', 12.345 ), + array( 'zero', 20 ), + array( 'other', 22 ), + array( 'one', 31 ), + array( 'zero', 200 ), + ); + } +} diff --git a/tests/phpunit/languages/classes/LanguageMgTest.php b/tests/phpunit/languages/classes/LanguageMgTest.php new file mode 100644 index 00000000..65e8fd7b --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageMgTest.php @@ -0,0 +1,36 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static 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/classes/LanguageMkTest.php b/tests/phpunit/languages/classes/LanguageMkTest.php new file mode 100644 index 00000000..ed155263 --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageMkTest.php @@ -0,0 +1,40 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static function providePlural() { + return array( + array( 'other', 0 ), + array( 'one', 1 ), + array( 'one', 11 ), + array( 'one', 21 ), + array( 'one', 411 ), + array( 'other', 12.345 ), + array( 'other', 20 ), + array( 'one', 31 ), + array( 'other', 200 ), + ); + } +} diff --git a/tests/phpunit/languages/classes/LanguageMlTest.php b/tests/phpunit/languages/classes/LanguageMlTest.php new file mode 100644 index 00000000..4fa45ce3 --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageMlTest.php @@ -0,0 +1,38 @@ +assertEquals( $result, $this->getLang()->formatNum( $value ) ); + } + + public static 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/classes/LanguageMoTest.php b/tests/phpunit/languages/classes/LanguageMoTest.php new file mode 100644 index 00000000..e0e54ca8 --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageMoTest.php @@ -0,0 +1,45 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static function providePlural() { + 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/classes/LanguageMtTest.php b/tests/phpunit/languages/classes/LanguageMtTest.php new file mode 100644 index 00000000..96d2bc92 --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageMtTest.php @@ -0,0 +1,77 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static function providePlural() { + 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 providePluralTwoForms + * @covers Language::convertPlural + */ + public function testPluralTwoForms( $result, $value ) { + $forms = array( 'one', 'other' ); + $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + public static function providePluralTwoForms() { + return array( + array( 'other', 0 ), + array( 'one', 1 ), + array( 'other', 2 ), + array( 'other', 10 ), + array( 'other', 11 ), + array( 'other', 19 ), + array( 'other', 20 ), + array( 'other', 99 ), + array( 'other', 100 ), + array( 'other', 101 ), + array( 'other', 102 ), + array( 'other', 110 ), + array( 'other', 111 ), + array( 'other', 119 ), + array( 'other', 120 ), + array( 'other', 201 ), + ); + } +} diff --git a/tests/phpunit/languages/classes/LanguageNlTest.php b/tests/phpunit/languages/classes/LanguageNlTest.php new file mode 100644 index 00000000..26bd691a --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageNlTest.php @@ -0,0 +1,24 @@ +assertEquals( '1.234.567', $this->getLang()->formatNum( '1234567' ) ); + $this->assertEquals( '12.345', $this->getLang()->formatNum( '12345' ) ); + $this->assertEquals( '1', $this->getLang()->formatNum( '1' ) ); + $this->assertEquals( '123', $this->getLang()->formatNum( '123' ) ); + $this->assertEquals( '1.234', $this->getLang()->formatNum( '1234' ) ); + $this->assertEquals( '12.345,56', $this->getLang()->formatNum( '12345.56' ) ); + $this->assertEquals( ',1234556', $this->getLang()->formatNum( '.1234556' ) ); + } +} diff --git a/tests/phpunit/languages/classes/LanguageNsoTest.php b/tests/phpunit/languages/classes/LanguageNsoTest.php new file mode 100644 index 00000000..18efd736 --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageNsoTest.php @@ -0,0 +1,34 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static function providePlural() { + return array( + array( 'one', 0 ), + array( 'one', 1 ), + array( 'other', 2 ), + ); + } +} diff --git a/tests/phpunit/languages/classes/LanguagePlTest.php b/tests/phpunit/languages/classes/LanguagePlTest.php new file mode 100644 index 00000000..d180037b --- /dev/null +++ b/tests/phpunit/languages/classes/LanguagePlTest.php @@ -0,0 +1,77 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static function providePlural() { + 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 providePluralTwoForms + * @covers Language::convertPlural + */ + public function testPluralTwoForms( $result, $value ) { + $forms = array( 'one', 'other' ); + $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + public static function providePluralTwoForms() { + return array( + array( 'other', 0 ), + array( 'one', 1 ), + array( 'other', 2 ), + array( 'other', 3 ), + array( 'other', 4 ), + array( 'other', 5 ), + array( 'other', 9 ), + array( 'other', 10 ), + array( 'other', 11 ), + array( 'other', 21 ), + array( 'other', 22 ), + array( 'other', 23 ), + array( 'other', 24 ), + array( 'other', 25 ), + array( 'other', 200 ), + array( 'other', 201 ), + ); + } +} diff --git a/tests/phpunit/languages/classes/LanguageRoTest.php b/tests/phpunit/languages/classes/LanguageRoTest.php new file mode 100644 index 00000000..ae7816bc --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageRoTest.php @@ -0,0 +1,45 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static function providePlural() { + 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/classes/LanguageRuTest.php b/tests/phpunit/languages/classes/LanguageRuTest.php new file mode 100644 index 00000000..1381afbf --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageRuTest.php @@ -0,0 +1,115 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * Test explicit plural forms - n=FormN forms + * @covers Language::convertPlural + */ + public function testExplicitPlural() { + $forms = array( 'one', 'few', 'many', 'other', '12=dozen' ); + $this->assertEquals( 'dozen', $this->getLang()->convertPlural( 12, $forms ) ); + $forms = array( 'one', 'few', 'many', '100=hundred', 'other', '12=dozen' ); + $this->assertEquals( 'hundred', $this->getLang()->convertPlural( 100, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static 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 ), + ); + } + + /** + * @dataProvider providePluralTwoForms + * @covers Language::convertPlural + */ + public function testPluralTwoForms( $result, $value ) { + $forms = array( '1=one', 'other' ); + $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + public static function providePluralTwoForms() { + return array( + array( 'one', 1 ), + array( 'other', 11 ), + array( 'other', 91 ), + array( 'other', 121 ), + ); + } + + /** + * @dataProvider providerGrammar + * @covers Language::convertGrammar + */ + public function testGrammar( $result, $word, $case ) { + $this->assertEquals( $result, $this->getLang()->convertGrammar( $word, $case ) ); + } + + public static function providerGrammar() { + return array( + array( + 'Википедии', + 'Википедия', + 'genitive', + ), + array( + 'Викитеки', + 'Викитека', + 'genitive', + ), + array( + 'Викитеке', + 'Викитека', + 'prepositional', + ), + array( + 'Викисклада', + 'Викисклад', + 'genitive', + ), + array( + 'Викискладе', + 'Викисклад', + 'prepositional', + ), + array( + 'Викиданных', + 'Викиданные', + 'prepositional', + ), + ); + } +} diff --git a/tests/phpunit/languages/classes/LanguageSeTest.php b/tests/phpunit/languages/classes/LanguageSeTest.php new file mode 100644 index 00000000..533aa2bc --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageSeTest.php @@ -0,0 +1,53 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static function providePlural() { + return array( + array( 'other', 0 ), + array( 'one', 1 ), + array( 'two', 2 ), + array( 'other', 3 ), + ); + } + + /** + * @dataProvider providePluralTwoForms + * @covers Language::convertPlural + */ + public function testPluralTwoForms( $result, $value ) { + $forms = array( 'one', 'other' ); + $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + public static function providePluralTwoForms() { + return array( + array( 'other', 0 ), + array( 'one', 1 ), + array( 'other', 2 ), + array( 'other', 3 ), + ); + } +} diff --git a/tests/phpunit/languages/classes/LanguageSgsTest.php b/tests/phpunit/languages/classes/LanguageSgsTest.php new file mode 100644 index 00000000..fa49a4dd --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageSgsTest.php @@ -0,0 +1,71 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providePluralAllForms + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static function providePluralAllForms() { + return array( + array( 'few', 0 ), + array( 'one', 1 ), + array( 'two', 2 ), + array( 'other', 3 ), + array( 'few', 10 ), + array( 'few', 11 ), + array( 'few', 12 ), + array( 'few', 19 ), + array( 'other', 20 ), + array( 'few', 100 ), + array( 'one', 101 ), + array( 'few', 111 ), + array( 'few', 112 ), + ); + } + + /** + * @dataProvider providePluralTwoForms + * @covers Language::convertPlural + */ + public function testPluralTwoForms( $result, $value ) { + $forms = array( 'one', 'other' ); + $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + public static 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/classes/LanguageShTest.php b/tests/phpunit/languages/classes/LanguageShTest.php new file mode 100644 index 00000000..1b390872 --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageShTest.php @@ -0,0 +1,42 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static function providePlural() { + return array( + array( 'other', 0 ), + array( 'one', 1 ), + array( 'few', 2 ), + array( 'few', 4 ), + array( 'other', 5 ), + array( 'other', 10 ), + array( 'other', 11 ), + array( 'other', 12 ), + array( 'one', 101 ), + array( 'few', 102 ), + array( 'other', 111 ), + ); + } +} diff --git a/tests/phpunit/languages/classes/LanguageSkTest.php b/tests/phpunit/languages/classes/LanguageSkTest.php new file mode 100644 index 00000000..cb8a13b8 --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageSkTest.php @@ -0,0 +1,42 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static function providePlural() { + 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/classes/LanguageSlTest.php b/tests/phpunit/languages/classes/LanguageSlTest.php new file mode 100644 index 00000000..9783dd80 --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageSlTest.php @@ -0,0 +1,44 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providerPlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static function providerPlural() { + return array( + array( 'other', 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/classes/LanguageSmaTest.php b/tests/phpunit/languages/classes/LanguageSmaTest.php new file mode 100644 index 00000000..95cb333c --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageSmaTest.php @@ -0,0 +1,53 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static function providePlural() { + return array( + array( 'other', 0 ), + array( 'one', 1 ), + array( 'two', 2 ), + array( 'other', 3 ), + ); + } + + /** + * @dataProvider providePluralTwoForms + * @covers Language::convertPlural + */ + public function testPluralTwoForms( $result, $value ) { + $forms = array( 'one', 'other' ); + $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + public static function providePluralTwoForms() { + return array( + array( 'other', 0 ), + array( 'one', 1 ), + array( 'other', 2 ), + array( 'other', 3 ), + ); + } +} diff --git a/tests/phpunit/languages/classes/LanguageSrTest.php b/tests/phpunit/languages/classes/LanguageSrTest.php new file mode 100644 index 00000000..bfb199f3 --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageSrTest.php @@ -0,0 +1,249 @@ + + * @copyright Copyright © 2011, Antoine Musso + * @file + * + * @todo methods in test class should be tidied: + * - Should be split into separate test methods and data providers + * - Tests for LanguageConverter and Language should probably be separate.. + */ + +/** Tests for MediaWiki languages/LanguageSr.php */ +class LanguageSrTest extends LanguageClassesTestCase { + /** + * @covers LanguageConverter::convertTo + */ + public function testEasyConversions() { + $this->assertCyrillic( + 'шђчћжШЂЧЋЖ', + 'Cyrillic guessing characters' + ); + $this->assertLatin( + 'šđč枊ĐČĆŽ', + 'Latin guessing characters' + ); + } + + /** + * @covers LanguageConverter::convertTo + */ + public function testMixedConversions() { + $this->assertCyrillic( + 'шђчћжШЂЧЋЖ - šđčćž', + 'Mostly cyrillic characters' + ); + $this->assertLatin( + 'šđč枊ĐČĆŽ - шђчћж', + 'Mostly latin characters' + ); + } + + /** + * @covers LanguageConverter::convertTo + */ + public function testSameAmountOfLatinAndCyrillicGetConverted() { + $this->assertConverted( + '4 latin: šđčć | 4 cyrillic: шђчћ', + 'sr-ec' + ); + $this->assertConverted( + '4 latin: šđčć | 4 cyrillic: шђчћ', + 'sr-el' + ); + } + + /** + * @author Nikola Smolenski + * @covers LanguageConverter::convertTo + */ + public function testConversionToCyrillic() { + //A simple convertion of Latin to Cyrillic + $this->assertEquals( 'абвг', + $this->convertToCyrillic( 'abvg' ) + ); + //Same as above, but assert that -{}-s must be removed and not converted + $this->assertEquals( 'ljабnjвгdž', + $this->convertToCyrillic( '-{lj}-ab-{nj}-vg-{dž}-' ) + ); + //A simple convertion of Cyrillic to Cyrillic + $this->assertEquals( 'абвг', + $this->convertToCyrillic( 'абвг' ) + ); + //Same as above, but assert that -{}-s must be removed and not converted + $this->assertEquals( 'ljабnjвгdž', + $this->convertToCyrillic( '-{lj}-аб-{nj}-вг-{dž}-' ) + ); + //This text has some Latin, but is recognized as Cyrillic, so it should not be converted + $this->assertEquals( 'abvgшђжчћ', + $this->convertToCyrillic( 'abvgшђжчћ' ) + ); + //Same as above, but assert that -{}-s must be removed + $this->assertEquals( 'љabvgњшђжчћџ', + $this->convertToCyrillic( '-{љ}-abvg-{њ}-шђжчћ-{џ}-' ) + ); + //This text has some Cyrillic, but is recognized as Latin, so it should be converted + $this->assertEquals( 'абвгшђжчћ', + $this->convertToCyrillic( 'абвгšđžčć' ) + ); + //Same as above, but assert that -{}-s must be removed and not converted + $this->assertEquals( 'ljабвгnjшђжчћdž', + $this->convertToCyrillic( '-{lj}-абвг-{nj}-šđžčć-{dž}-' ) + ); + // Roman numerals are not converted + $this->assertEquals( 'а I б II в III г IV шђжчћ', + $this->convertToCyrillic( 'a I b II v III g IV šđžčć' ) + ); + } + + /** + * @covers LanguageConverter::convertTo + */ + public function testConversionToLatin() { + //A simple convertion of Latin to Latin + $this->assertEquals( 'abcd', + $this->convertToLatin( 'abcd' ) + ); + //A simple convertion of Cyrillic to Latin + $this->assertEquals( 'abcd', + $this->convertToLatin( 'абцд' ) + ); + //This text has some Latin, but is recognized as Cyrillic, so it should be converted + $this->assertEquals( 'abcdšđžčć', + $this->convertToLatin( 'abcdшђжчћ' ) + ); + //This text has some Cyrillic, but is recognized as Latin, so it should not be converted + $this->assertEquals( 'абцдšđžčć', + $this->convertToLatin( 'абцдšđžčć' ) + ); + } + + /** + * @dataProvider providePlural + * @covers Language::convertPlural + */ + public function testPlural( $result, $value ) { + $forms = array( 'one', 'few', 'other' ); + $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static function providePlural() { + return array( + array( 'one', 1 ), + array( 'other', 11 ), + array( 'one', 91 ), + array( 'one', 121 ), + array( 'few', 2 ), + array( 'few', 3 ), + array( 'few', 4 ), + array( 'few', 334 ), + array( 'other', 5 ), + array( 'other', 15 ), + array( 'other', 120 ), + ); + } + + /** + * @dataProvider providePluralTwoForms + * @covers Language::convertPlural + */ + public function testPluralTwoForms( $result, $value ) { + $forms = array( 'one', 'other' ); + $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + public static function providePluralTwoForms() { + return array( + array( 'one', 1 ), + array( 'other', 11 ), + array( 'other', 4 ), + array( 'one', 91 ), + array( 'one', 121 ), + ); + } + + ##### HELPERS ##################################################### + /** + *Wrapper to verify text stay the same after applying conversion + * @param string $text Text to convert + * @param string $variant Language variant 'sr-ec' or 'sr-el' + * @param string $msg Optional message + */ + protected 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 string $text Text to convert + * @param string $variant Language variant 'sr-ec' or 'sr-el' + * @param string $msg Optional message + */ + protected 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. + * @param string $text Text to convert + * @param string $msg Optional message + */ + protected 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. + * @param string $text Text to convert + * @param string $msg Optional message + */ + protected function assertLatin( $text, $msg = '' ) { + $this->assertUnConverted( $text, 'sr-el', $msg ); + $this->assertConverted( $text, 'sr-ec', $msg ); + } + + /** Wrapper for converter::convertTo() method*/ + protected function convertTo( $text, $variant ) { + return $this->getLang() + ->mConverter + ->convertTo( + $text, $variant + ); + } + + protected function convertToCyrillic( $text ) { + return $this->convertTo( $text, 'sr-ec' ); + } + + protected function convertToLatin( $text ) { + return $this->convertTo( $text, 'sr-el' ); + } +} diff --git a/tests/phpunit/languages/classes/LanguageTiTest.php b/tests/phpunit/languages/classes/LanguageTiTest.php new file mode 100644 index 00000000..e225af97 --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageTiTest.php @@ -0,0 +1,34 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static function providePlural() { + return array( + array( 'one', 0 ), + array( 'one', 1 ), + array( 'other', 2 ), + ); + } +} diff --git a/tests/phpunit/languages/classes/LanguageTlTest.php b/tests/phpunit/languages/classes/LanguageTlTest.php new file mode 100644 index 00000000..20f5bd7f --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageTlTest.php @@ -0,0 +1,36 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static function providePlural() { + return array( + array( 'one', 0 ), + array( 'one', 1 ), + array( 'one', 2 ), + array( 'other', 4 ), + array( 'other', 6 ), + ); + } +} diff --git a/tests/phpunit/languages/classes/LanguageTrTest.php b/tests/phpunit/languages/classes/LanguageTrTest.php new file mode 100644 index 00000000..2c9905f7 --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageTrTest.php @@ -0,0 +1,61 @@ +getLang()->ucfirst( $input ); + } elseif ( $func == 'lcfirst' ) { + $res = $this->getLang()->lcfirst( $input ); + } else { + throw new MWException( __METHOD__ . " given an invalid function name '$func'" ); + } + + $msg = "Converting $inputCase case '$input' with $func should give '$expected'"; + + $this->assertEquals( $expected, $res, $msg ); + } + + public static function provideDottedAndDotlessI() { + return array( + # function, input, input case, expected + # Case changed: + array( 'ucfirst', 'ı', 'lower', 'I' ), + array( 'ucfirst', 'i', 'lower', 'İ' ), + array( 'lcfirst', 'I', 'upper', 'ı' ), + array( 'lcfirst', 'İ', 'upper', 'i' ), + + # Already using the correct case + array( 'ucfirst', 'I', 'upper', 'I' ), + array( 'ucfirst', 'İ', 'upper', 'İ' ), + array( 'lcfirst', 'ı', 'lower', 'ı' ), + array( 'lcfirst', 'i', 'lower', 'i' ), + + # A real example taken from bug 28040 using + # http://tr.wikipedia.org/wiki/%C4%B0Phone + array( 'lcfirst', 'iPhone', 'lower', 'iPhone' ), + + # next case is valid in Turkish but are different words if we + # consider IPhone is English! + array( 'lcfirst', 'IPhone', 'upper', 'ıPhone' ), + + ); + } +} diff --git a/tests/phpunit/languages/classes/LanguageUkTest.php b/tests/phpunit/languages/classes/LanguageUkTest.php new file mode 100644 index 00000000..9051bcff --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageUkTest.php @@ -0,0 +1,72 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * Test explicit plural forms - n=FormN forms + * @covers Language::convertPlural + */ + public function testExplicitPlural() { + $forms = array( 'one', 'few', 'many', 'other', '12=dozen' ); + $this->assertEquals( 'dozen', $this->getLang()->convertPlural( 12, $forms ) ); + $forms = array( 'one', 'few', 'many', '100=hundred', 'other', '12=dozen' ); + $this->assertEquals( 'hundred', $this->getLang()->convertPlural( 100, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static 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 ), + ); + } + + /** + * @dataProvider providePluralTwoForms + * @covers Language::convertPlural + */ + public function testPluralTwoForms( $result, $value ) { + $forms = array( '1=one', 'other' ); + $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + public static function providePluralTwoForms() { + return array( + array( 'one', 1 ), + array( 'other', 11 ), + array( 'other', 91 ), + array( 'other', 121 ), + ); + } +} diff --git a/tests/phpunit/languages/classes/LanguageUzTest.php b/tests/phpunit/languages/classes/LanguageUzTest.php new file mode 100644 index 00000000..4881103f --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageUzTest.php @@ -0,0 +1,124 @@ + + * @copyright Copyright © 2012, Robin Pepermans + * @copyright Copyright © 2011, Antoine Musso + * @file + * + * @todo methods in test class should be tidied: + * - Should be split into separate test methods and data providers + * - Tests for LanguageConverter and Language should probably be separate.. + */ + +/** Tests for MediaWiki languages/LanguageUz.php */ +class LanguageUzTest extends LanguageClassesTestCase { + + /** + * @author Nikola Smolenski + * @covers LanguageConverter::convertTo + */ + public function testConversionToCyrillic() { + // A convertion of Latin to Cyrillic + $this->assertEquals( 'абвгғ', + $this->convertToCyrillic( 'abvggʻ' ) + ); + // Same as above, but assert that -{}-s must be removed and not converted + $this->assertEquals( 'ljабnjвгўоdb', + $this->convertToCyrillic( '-{lj}-ab-{nj}-vgoʻo-{db}-' ) + ); + // A simple convertion of Cyrillic to Cyrillic + $this->assertEquals( 'абвг', + $this->convertToCyrillic( 'абвг' ) + ); + // Same as above, but assert that -{}-s must be removed and not converted + $this->assertEquals( 'ljабnjвгdaž', + $this->convertToCyrillic( '-{lj}-аб-{nj}-вг-{da}-ž' ) + ); + } + + /** + * @covers LanguageConverter::convertTo + */ + public function testConversionToLatin() { + // A simple convertion of Latin to Latin + $this->assertEquals( 'abdef', + $this->convertToLatin( 'abdef' ) + ); + // A convertion of Cyrillic to Latin + $this->assertEquals( 'gʻabtsdOʻQyo', + $this->convertToLatin( 'ғабцдЎҚё' ) + ); + } + + ##### HELPERS ##################################################### + /** + * Wrapper to verify text stay the same after applying conversion + * @param string $text Text to convert + * @param string $variant Language variant 'uz-cyrl' or 'uz-latn' + * @param string $msg Optional message + */ + protected 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 string $text Text to convert + * @param string $variant Language variant 'uz-cyrl' or 'uz-latn' + * @param string $msg Optional message + */ + protected 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. + * @param string $text Text to convert + * @param string $msg Optional message + */ + protected function assertCyrillic( $text, $msg = '' ) { + $this->assertUnConverted( $text, 'uz-cyrl', $msg ); + $this->assertConverted( $text, 'uz-latn', $msg ); + } + + /** + * Verifiy the given Latin text is not converted when using + * using the Latin variant and converted to Cyrillic when using + * the Cyrillic variant. + * @param string $text Text to convert + * @param string $msg Optional message + */ + protected function assertLatin( $text, $msg = '' ) { + $this->assertUnConverted( $text, 'uz-latn', $msg ); + $this->assertConverted( $text, 'uz-cyrl', $msg ); + } + + /** Wrapper for converter::convertTo() method*/ + protected function convertTo( $text, $variant ) { + return $this->getLang()->mConverter->convertTo( $text, $variant ); + } + + protected function convertToCyrillic( $text ) { + return $this->convertTo( $text, 'uz-cyrl' ); + } + + protected function convertToLatin( $text ) { + return $this->convertTo( $text, 'uz-latn' ); + } +} diff --git a/tests/phpunit/languages/classes/LanguageWaTest.php b/tests/phpunit/languages/classes/LanguageWaTest.php new file mode 100644 index 00000000..d05196c0 --- /dev/null +++ b/tests/phpunit/languages/classes/LanguageWaTest.php @@ -0,0 +1,34 @@ +assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** + * @dataProvider providePlural + * @covers Language::getPluralRuleType + */ + public function testGetPluralRuleType( $result, $value ) { + $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); + } + + public static function providePlural() { + return array( + array( 'one', 0 ), + array( 'one', 1 ), + array( 'other', 2 ), + ); + } +} -- cgit v1.2.2