2011-11-16 15:12:00 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
/**
|
|
|
|
|
|
* PHPUnit tests for the Serbian language.
|
|
|
|
|
|
* The language can be represented using two scripts:
|
|
|
|
|
|
* - Latin (SR_el)
|
|
|
|
|
|
* - Cyrillic (SR_ec)
|
|
|
|
|
|
* Both representations seems to be bijective, hence MediaWiki can convert
|
|
|
|
|
|
* from one script to the other.
|
|
|
|
|
|
*
|
|
|
|
|
|
* @author Antoine Musso <hashar at free dot fr>
|
|
|
|
|
|
* @copyright Copyright © 2011, Antoine Musso <hashar at free dot fr>
|
|
|
|
|
|
* @file
|
2013-10-22 10:32:29 +00:00
|
|
|
|
*
|
|
|
|
|
|
* @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..
|
2011-11-16 15:12:00 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
2012-07-27 13:56:50 +00:00
|
|
|
|
/** Tests for MediaWiki languages/LanguageSr.php */
|
2012-10-23 20:53:17 +00:00
|
|
|
|
class LanguageSrTest extends LanguageClassesTestCase {
|
2013-10-22 10:32:29 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* @covers LanguageConverter::convertTo
|
|
|
|
|
|
*/
|
|
|
|
|
|
public function testEasyConversions() {
|
2011-11-16 15:12:00 +00:00
|
|
|
|
$this->assertCyrillic(
|
|
|
|
|
|
'шђчћжШЂЧЋЖ',
|
|
|
|
|
|
'Cyrillic guessing characters'
|
|
|
|
|
|
);
|
|
|
|
|
|
$this->assertLatin(
|
|
|
|
|
|
'šđč枊ĐČĆŽ',
|
|
|
|
|
|
'Latin guessing characters'
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2013-10-22 10:32:29 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* @covers LanguageConverter::convertTo
|
|
|
|
|
|
*/
|
|
|
|
|
|
public function testMixedConversions() {
|
2011-11-16 15:12:00 +00:00
|
|
|
|
$this->assertCyrillic(
|
|
|
|
|
|
'шђчћжШЂЧЋЖ - šđčćž',
|
|
|
|
|
|
'Mostly cyrillic characters'
|
|
|
|
|
|
);
|
|
|
|
|
|
$this->assertLatin(
|
|
|
|
|
|
'šđč枊ĐČĆŽ - шђчћж',
|
|
|
|
|
|
'Mostly latin characters'
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2013-10-22 10:32:29 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* @covers LanguageConverter::convertTo
|
|
|
|
|
|
*/
|
|
|
|
|
|
public function testSameAmountOfLatinAndCyrillicGetConverted() {
|
2011-11-16 15:12:00 +00:00
|
|
|
|
$this->assertConverted(
|
|
|
|
|
|
'4 latin: šđčć | 4 cyrillic: шђчћ',
|
|
|
|
|
|
'sr-ec'
|
|
|
|
|
|
);
|
|
|
|
|
|
$this->assertConverted(
|
|
|
|
|
|
'4 latin: šđčć | 4 cyrillic: шђчћ',
|
|
|
|
|
|
'sr-el'
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2012-02-02 11:14:26 +00:00
|
|
|
|
* @author Nikola Smolenski
|
2013-10-22 10:32:29 +00:00
|
|
|
|
* @covers LanguageConverter::convertTo
|
2011-11-16 15:12:00 +00:00
|
|
|
|
*/
|
2013-10-22 10:32:29 +00:00
|
|
|
|
public function testConversionToCyrillic() {
|
2015-09-11 13:44:59 +00:00
|
|
|
|
// A simple convertion of Latin to Cyrillic
|
2011-11-16 15:12:00 +00:00
|
|
|
|
$this->assertEquals( 'абвг',
|
|
|
|
|
|
$this->convertToCyrillic( 'abvg' )
|
|
|
|
|
|
);
|
2015-09-11 13:44:59 +00:00
|
|
|
|
// Same as above, but assert that -{}-s must be removed and not converted
|
2012-04-10 16:36:51 +00:00
|
|
|
|
$this->assertEquals( 'ljабnjвгdž',
|
|
|
|
|
|
$this->convertToCyrillic( '-{lj}-ab-{nj}-vg-{dž}-' )
|
|
|
|
|
|
);
|
2015-09-11 13:44:59 +00:00
|
|
|
|
// A simple convertion of Cyrillic to Cyrillic
|
2011-11-16 15:12:00 +00:00
|
|
|
|
$this->assertEquals( 'абвг',
|
|
|
|
|
|
$this->convertToCyrillic( 'абвг' )
|
|
|
|
|
|
);
|
2015-09-11 13:44:59 +00:00
|
|
|
|
// Same as above, but assert that -{}-s must be removed and not converted
|
2012-04-10 16:36:51 +00:00
|
|
|
|
$this->assertEquals( 'ljабnjвгdž',
|
|
|
|
|
|
$this->convertToCyrillic( '-{lj}-аб-{nj}-вг-{dž}-' )
|
|
|
|
|
|
);
|
2015-09-11 13:44:59 +00:00
|
|
|
|
// This text has some Latin, but is recognized as Cyrillic, so it should not be converted
|
2011-11-16 15:12:00 +00:00
|
|
|
|
$this->assertEquals( 'abvgшђжчћ',
|
|
|
|
|
|
$this->convertToCyrillic( 'abvgшђжчћ' )
|
|
|
|
|
|
);
|
2015-09-11 13:44:59 +00:00
|
|
|
|
// Same as above, but assert that -{}-s must be removed
|
2012-04-10 16:36:51 +00:00
|
|
|
|
$this->assertEquals( 'љabvgњшђжчћџ',
|
|
|
|
|
|
$this->convertToCyrillic( '-{љ}-abvg-{њ}-шђжчћ-{џ}-' )
|
|
|
|
|
|
);
|
2015-09-11 13:44:59 +00:00
|
|
|
|
// This text has some Cyrillic, but is recognized as Latin, so it should be converted
|
2011-11-16 15:12:00 +00:00
|
|
|
|
$this->assertEquals( 'абвгшђжчћ',
|
|
|
|
|
|
$this->convertToCyrillic( 'абвгšđžčć' )
|
|
|
|
|
|
);
|
2015-09-11 13:44:59 +00:00
|
|
|
|
// Same as above, but assert that -{}-s must be removed and not converted
|
2012-04-10 16:36:51 +00:00
|
|
|
|
$this->assertEquals( 'ljабвгnjшђжчћdž',
|
|
|
|
|
|
$this->convertToCyrillic( '-{lj}-абвг-{nj}-šđžčć-{dž}-' )
|
|
|
|
|
|
);
|
2012-02-02 11:14:26 +00:00
|
|
|
|
// Roman numerals are not converted
|
2011-11-16 15:12:00 +00:00
|
|
|
|
$this->assertEquals( 'а I б II в III г IV шђжчћ',
|
|
|
|
|
|
$this->convertToCyrillic( 'a I b II v III g IV šđžčć' )
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2013-10-22 10:32:29 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* @covers LanguageConverter::convertTo
|
|
|
|
|
|
*/
|
|
|
|
|
|
public function testConversionToLatin() {
|
2015-09-11 13:44:59 +00:00
|
|
|
|
// A simple convertion of Latin to Latin
|
2011-11-16 15:12:00 +00:00
|
|
|
|
$this->assertEquals( 'abcd',
|
|
|
|
|
|
$this->convertToLatin( 'abcd' )
|
|
|
|
|
|
);
|
2015-09-11 13:44:59 +00:00
|
|
|
|
// A simple convertion of Cyrillic to Latin
|
2011-11-16 15:12:00 +00:00
|
|
|
|
$this->assertEquals( 'abcd',
|
|
|
|
|
|
$this->convertToLatin( 'абцд' )
|
|
|
|
|
|
);
|
2015-09-11 13:44:59 +00:00
|
|
|
|
// This text has some Latin, but is recognized as Cyrillic, so it should be converted
|
2011-11-16 15:12:00 +00:00
|
|
|
|
$this->assertEquals( 'abcdšđžčć',
|
|
|
|
|
|
$this->convertToLatin( 'abcdшђжчћ' )
|
|
|
|
|
|
);
|
2015-09-11 13:44:59 +00:00
|
|
|
|
// This text has some Cyrillic, but is recognized as Latin, so it should not be converted
|
2011-11-16 15:12:00 +00:00
|
|
|
|
$this->assertEquals( 'абцдšđžčć',
|
|
|
|
|
|
$this->convertToLatin( 'абцдšđžčć' )
|
|
|
|
|
|
);
|
2012-02-01 15:59:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2013-10-22 10:32:29 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* @dataProvider providePlural
|
|
|
|
|
|
* @covers Language::convertPlural
|
|
|
|
|
|
*/
|
|
|
|
|
|
public function testPlural( $result, $value ) {
|
Update plural rules to CLDR 24
Updated plurals.xml with new data from CLDR 24.
This data is according to UTS #35 Rev 33.
Update the CLDRPluralRuleParser.js to version 1.1 from upstream
https://github.com/santhoshtr/CLDRPluralRuleParser
Changes to the plural rules:
* Hebrew override removed since CLDR 24 matches with MW plural rules.
* Updated the syntax of overridden rules to TR35 Rev 33 for
Lower Sorbian (dsb), Upper Sorbian (hsb), Belarusian in Taraskievica
orthography (be_tarask), Old Church Slavonic (cu), Bhojpuri (bho),
Samogitian (sgs).
* Removed Manx (gv) override. See I46ab3dadc7fe08c1e60bbd81a1ee841e166e9608.
* Removed the overriden convertPlural method for Serbian from LanguageSr.php,
since CLDR 24 matches with MW rules. Updated and added more tests.
Tests updated for Serbocroatian (sh), too. Old CLDR versions had 4 plural
rules and MW had only 3. In CLDR 24, the form 'many' was removed and it
became identical to the MW. Same for Bosnian (bs) and Croatian (hr).
Also for variants sr-ec and sr-el
* Macedonian (mk) used to count 11 as 'other' form.
CLDR 24 counts it as 'one'.
Not overriding, using CLDR 24 here.
Updated the tests. MW will not override this.
* Armenian (hy) used to count 0 as 'other'.
Now it is 'one' form.
Updated the tests. MW will not override this.
* Latvian (lv) used to count only 0 as 'zero' form, but CLDR 24, any number
satisifying the following formula is counted as zero:
n % 10 = 0 or n % 100 = 11..19 or v = 2 and f % 100 = 11..19
Examples: 0, 10~20, 30, 40, 50, 60, 100.
Updated the tests accordingly. Not overriding it in MW.
Users will see different plural form for the above numbers.
* Removed Ukranian custom plural rule since it match with MW
* Russian (ru) plural rules have a major change.
The 'few' form is merged with the 'other' form.
The current forms are 'one', 'many', 'other'.
In MW ru plural rules were overridden using convertPlural methdod
in LanguagesRu.php with 3 forms.
Effectively forms[1] and forms[2] are swapped.
This will affect the messages, and such messages
must be reviewed and updated. This change is not included in this patch and
wil be done separately.
Russian is the only remaining language class with convertPlural method overridden.
Notable impact on the exising messages:
* For languages ru, uk, be_tarask, sr, For the special case
of two plural forms and first mapped to 1 and rest to the other form, syntax like
{{plural:$1|1=one|other}} should be used.
For further information regarding each of the above language changes, see
1. http://unicode.org/cldr/trac/ticket/3727
2. http://goo.gl/H2HEz
CLDR 24 can handle fractions. Ideally it should start working
in MW without any code changes, but MW language test suite
does not have enough tests to confirm.
Followup: e571717e06667228ec8d689be067e00bdd06d34d
Bug: 56931
Change-Id: I9930b290d004667a3bb09e5c1663ec2c9c27d8a6
2014-01-01 09:05:39 +00:00
|
|
|
|
$forms = array( 'one', 'few', 'other' );
|
2012-10-23 20:53:17 +00:00
|
|
|
|
$this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
|
2012-02-01 15:59:26 +00:00
|
|
|
|
}
|
2011-11-16 15:12:00 +00:00
|
|
|
|
|
2013-10-22 10:32:29 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* @dataProvider providePlural
|
|
|
|
|
|
* @covers Language::getPluralRuleType
|
|
|
|
|
|
*/
|
|
|
|
|
|
public function testGetPluralRuleType( $result, $value ) {
|
2013-01-25 01:10:37 +00:00
|
|
|
|
$this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) );
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2013-03-22 02:12:37 +00:00
|
|
|
|
public static function providePlural() {
|
2013-03-25 23:27:14 +00:00
|
|
|
|
return array(
|
2012-02-01 15:59:26 +00:00
|
|
|
|
array( 'one', 1 ),
|
Update plural rules to CLDR 24
Updated plurals.xml with new data from CLDR 24.
This data is according to UTS #35 Rev 33.
Update the CLDRPluralRuleParser.js to version 1.1 from upstream
https://github.com/santhoshtr/CLDRPluralRuleParser
Changes to the plural rules:
* Hebrew override removed since CLDR 24 matches with MW plural rules.
* Updated the syntax of overridden rules to TR35 Rev 33 for
Lower Sorbian (dsb), Upper Sorbian (hsb), Belarusian in Taraskievica
orthography (be_tarask), Old Church Slavonic (cu), Bhojpuri (bho),
Samogitian (sgs).
* Removed Manx (gv) override. See I46ab3dadc7fe08c1e60bbd81a1ee841e166e9608.
* Removed the overriden convertPlural method for Serbian from LanguageSr.php,
since CLDR 24 matches with MW rules. Updated and added more tests.
Tests updated for Serbocroatian (sh), too. Old CLDR versions had 4 plural
rules and MW had only 3. In CLDR 24, the form 'many' was removed and it
became identical to the MW. Same for Bosnian (bs) and Croatian (hr).
Also for variants sr-ec and sr-el
* Macedonian (mk) used to count 11 as 'other' form.
CLDR 24 counts it as 'one'.
Not overriding, using CLDR 24 here.
Updated the tests. MW will not override this.
* Armenian (hy) used to count 0 as 'other'.
Now it is 'one' form.
Updated the tests. MW will not override this.
* Latvian (lv) used to count only 0 as 'zero' form, but CLDR 24, any number
satisifying the following formula is counted as zero:
n % 10 = 0 or n % 100 = 11..19 or v = 2 and f % 100 = 11..19
Examples: 0, 10~20, 30, 40, 50, 60, 100.
Updated the tests accordingly. Not overriding it in MW.
Users will see different plural form for the above numbers.
* Removed Ukranian custom plural rule since it match with MW
* Russian (ru) plural rules have a major change.
The 'few' form is merged with the 'other' form.
The current forms are 'one', 'many', 'other'.
In MW ru plural rules were overridden using convertPlural methdod
in LanguagesRu.php with 3 forms.
Effectively forms[1] and forms[2] are swapped.
This will affect the messages, and such messages
must be reviewed and updated. This change is not included in this patch and
wil be done separately.
Russian is the only remaining language class with convertPlural method overridden.
Notable impact on the exising messages:
* For languages ru, uk, be_tarask, sr, For the special case
of two plural forms and first mapped to 1 and rest to the other form, syntax like
{{plural:$1|1=one|other}} should be used.
For further information regarding each of the above language changes, see
1. http://unicode.org/cldr/trac/ticket/3727
2. http://goo.gl/H2HEz
CLDR 24 can handle fractions. Ideally it should start working
in MW without any code changes, but MW language test suite
does not have enough tests to confirm.
Followup: e571717e06667228ec8d689be067e00bdd06d34d
Bug: 56931
Change-Id: I9930b290d004667a3bb09e5c1663ec2c9c27d8a6
2014-01-01 09:05:39 +00:00
|
|
|
|
array( 'other', 11 ),
|
2012-02-01 15:59:26 +00:00
|
|
|
|
array( 'one', 91 ),
|
|
|
|
|
|
array( 'one', 121 ),
|
|
|
|
|
|
array( 'few', 2 ),
|
|
|
|
|
|
array( 'few', 3 ),
|
|
|
|
|
|
array( 'few', 4 ),
|
|
|
|
|
|
array( 'few', 334 ),
|
Update plural rules to CLDR 24
Updated plurals.xml with new data from CLDR 24.
This data is according to UTS #35 Rev 33.
Update the CLDRPluralRuleParser.js to version 1.1 from upstream
https://github.com/santhoshtr/CLDRPluralRuleParser
Changes to the plural rules:
* Hebrew override removed since CLDR 24 matches with MW plural rules.
* Updated the syntax of overridden rules to TR35 Rev 33 for
Lower Sorbian (dsb), Upper Sorbian (hsb), Belarusian in Taraskievica
orthography (be_tarask), Old Church Slavonic (cu), Bhojpuri (bho),
Samogitian (sgs).
* Removed Manx (gv) override. See I46ab3dadc7fe08c1e60bbd81a1ee841e166e9608.
* Removed the overriden convertPlural method for Serbian from LanguageSr.php,
since CLDR 24 matches with MW rules. Updated and added more tests.
Tests updated for Serbocroatian (sh), too. Old CLDR versions had 4 plural
rules and MW had only 3. In CLDR 24, the form 'many' was removed and it
became identical to the MW. Same for Bosnian (bs) and Croatian (hr).
Also for variants sr-ec and sr-el
* Macedonian (mk) used to count 11 as 'other' form.
CLDR 24 counts it as 'one'.
Not overriding, using CLDR 24 here.
Updated the tests. MW will not override this.
* Armenian (hy) used to count 0 as 'other'.
Now it is 'one' form.
Updated the tests. MW will not override this.
* Latvian (lv) used to count only 0 as 'zero' form, but CLDR 24, any number
satisifying the following formula is counted as zero:
n % 10 = 0 or n % 100 = 11..19 or v = 2 and f % 100 = 11..19
Examples: 0, 10~20, 30, 40, 50, 60, 100.
Updated the tests accordingly. Not overriding it in MW.
Users will see different plural form for the above numbers.
* Removed Ukranian custom plural rule since it match with MW
* Russian (ru) plural rules have a major change.
The 'few' form is merged with the 'other' form.
The current forms are 'one', 'many', 'other'.
In MW ru plural rules were overridden using convertPlural methdod
in LanguagesRu.php with 3 forms.
Effectively forms[1] and forms[2] are swapped.
This will affect the messages, and such messages
must be reviewed and updated. This change is not included in this patch and
wil be done separately.
Russian is the only remaining language class with convertPlural method overridden.
Notable impact on the exising messages:
* For languages ru, uk, be_tarask, sr, For the special case
of two plural forms and first mapped to 1 and rest to the other form, syntax like
{{plural:$1|1=one|other}} should be used.
For further information regarding each of the above language changes, see
1. http://unicode.org/cldr/trac/ticket/3727
2. http://goo.gl/H2HEz
CLDR 24 can handle fractions. Ideally it should start working
in MW without any code changes, but MW language test suite
does not have enough tests to confirm.
Followup: e571717e06667228ec8d689be067e00bdd06d34d
Bug: 56931
Change-Id: I9930b290d004667a3bb09e5c1663ec2c9c27d8a6
2014-01-01 09:05:39 +00:00
|
|
|
|
array( 'other', 5 ),
|
|
|
|
|
|
array( 'other', 15 ),
|
|
|
|
|
|
array( 'other', 120 ),
|
2012-02-01 15:59:26 +00:00
|
|
|
|
);
|
|
|
|
|
|
}
|
2013-02-15 10:27:48 +00:00
|
|
|
|
|
2013-10-22 10:32:29 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* @dataProvider providePluralTwoForms
|
|
|
|
|
|
* @covers Language::convertPlural
|
|
|
|
|
|
*/
|
|
|
|
|
|
public function testPluralTwoForms( $result, $value ) {
|
2013-01-25 01:10:37 +00:00
|
|
|
|
$forms = array( 'one', 'other' );
|
2012-10-23 20:53:17 +00:00
|
|
|
|
$this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
|
2012-02-01 15:59:26 +00:00
|
|
|
|
}
|
2013-02-15 10:27:48 +00:00
|
|
|
|
|
2013-03-22 02:12:37 +00:00
|
|
|
|
public static function providePluralTwoForms() {
|
2013-02-15 10:27:48 +00:00
|
|
|
|
return array(
|
2012-02-01 15:59:26 +00:00
|
|
|
|
array( 'one', 1 ),
|
2013-01-25 01:10:37 +00:00
|
|
|
|
array( 'other', 11 ),
|
Update plural rules to CLDR 24
Updated plurals.xml with new data from CLDR 24.
This data is according to UTS #35 Rev 33.
Update the CLDRPluralRuleParser.js to version 1.1 from upstream
https://github.com/santhoshtr/CLDRPluralRuleParser
Changes to the plural rules:
* Hebrew override removed since CLDR 24 matches with MW plural rules.
* Updated the syntax of overridden rules to TR35 Rev 33 for
Lower Sorbian (dsb), Upper Sorbian (hsb), Belarusian in Taraskievica
orthography (be_tarask), Old Church Slavonic (cu), Bhojpuri (bho),
Samogitian (sgs).
* Removed Manx (gv) override. See I46ab3dadc7fe08c1e60bbd81a1ee841e166e9608.
* Removed the overriden convertPlural method for Serbian from LanguageSr.php,
since CLDR 24 matches with MW rules. Updated and added more tests.
Tests updated for Serbocroatian (sh), too. Old CLDR versions had 4 plural
rules and MW had only 3. In CLDR 24, the form 'many' was removed and it
became identical to the MW. Same for Bosnian (bs) and Croatian (hr).
Also for variants sr-ec and sr-el
* Macedonian (mk) used to count 11 as 'other' form.
CLDR 24 counts it as 'one'.
Not overriding, using CLDR 24 here.
Updated the tests. MW will not override this.
* Armenian (hy) used to count 0 as 'other'.
Now it is 'one' form.
Updated the tests. MW will not override this.
* Latvian (lv) used to count only 0 as 'zero' form, but CLDR 24, any number
satisifying the following formula is counted as zero:
n % 10 = 0 or n % 100 = 11..19 or v = 2 and f % 100 = 11..19
Examples: 0, 10~20, 30, 40, 50, 60, 100.
Updated the tests accordingly. Not overriding it in MW.
Users will see different plural form for the above numbers.
* Removed Ukranian custom plural rule since it match with MW
* Russian (ru) plural rules have a major change.
The 'few' form is merged with the 'other' form.
The current forms are 'one', 'many', 'other'.
In MW ru plural rules were overridden using convertPlural methdod
in LanguagesRu.php with 3 forms.
Effectively forms[1] and forms[2] are swapped.
This will affect the messages, and such messages
must be reviewed and updated. This change is not included in this patch and
wil be done separately.
Russian is the only remaining language class with convertPlural method overridden.
Notable impact on the exising messages:
* For languages ru, uk, be_tarask, sr, For the special case
of two plural forms and first mapped to 1 and rest to the other form, syntax like
{{plural:$1|1=one|other}} should be used.
For further information regarding each of the above language changes, see
1. http://unicode.org/cldr/trac/ticket/3727
2. http://goo.gl/H2HEz
CLDR 24 can handle fractions. Ideally it should start working
in MW without any code changes, but MW language test suite
does not have enough tests to confirm.
Followup: e571717e06667228ec8d689be067e00bdd06d34d
Bug: 56931
Change-Id: I9930b290d004667a3bb09e5c1663ec2c9c27d8a6
2014-01-01 09:05:39 +00:00
|
|
|
|
array( 'other', 4 ),
|
|
|
|
|
|
array( 'one', 91 ),
|
|
|
|
|
|
array( 'one', 121 ),
|
2012-02-01 15:59:26 +00:00
|
|
|
|
);
|
2011-11-16 15:12:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2015-09-11 13:44:59 +00:00
|
|
|
|
# #### HELPERS #####################################################
|
2011-11-16 15:12:00 +00:00
|
|
|
|
/**
|
|
|
|
|
|
*Wrapper to verify text stay the same after applying conversion
|
2014-04-17 18:43:42 +00:00
|
|
|
|
* @param string $text Text to convert
|
|
|
|
|
|
* @param string $variant Language variant 'sr-ec' or 'sr-el'
|
|
|
|
|
|
* @param string $msg Optional message
|
2011-11-16 15:12:00 +00:00
|
|
|
|
*/
|
2013-10-22 10:32:29 +00:00
|
|
|
|
protected function assertUnConverted( $text, $variant, $msg = '' ) {
|
2011-11-16 15:12:00 +00:00
|
|
|
|
$this->assertEquals(
|
|
|
|
|
|
$text,
|
|
|
|
|
|
$this->convertTo( $text, $variant ),
|
|
|
|
|
|
$msg
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
2013-02-15 10:27:48 +00:00
|
|
|
|
|
2011-11-16 15:12:00 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* Wrapper to verify a text is different once converted to a variant.
|
2014-04-17 18:43:42 +00:00
|
|
|
|
* @param string $text Text to convert
|
|
|
|
|
|
* @param string $variant Language variant 'sr-ec' or 'sr-el'
|
|
|
|
|
|
* @param string $msg Optional message
|
2011-11-16 15:12:00 +00:00
|
|
|
|
*/
|
2013-10-22 10:32:29 +00:00
|
|
|
|
protected function assertConverted( $text, $variant, $msg = '' ) {
|
2011-11-16 15:12:00 +00:00
|
|
|
|
$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.
|
2014-04-17 18:43:42 +00:00
|
|
|
|
* @param string $text Text to convert
|
|
|
|
|
|
* @param string $msg Optional message
|
2011-11-16 15:12:00 +00:00
|
|
|
|
*/
|
2013-10-22 10:32:29 +00:00
|
|
|
|
protected function assertCyrillic( $text, $msg = '' ) {
|
2011-11-16 15:12:00 +00:00
|
|
|
|
$this->assertUnConverted( $text, 'sr-ec', $msg );
|
|
|
|
|
|
$this->assertConverted( $text, 'sr-el', $msg );
|
|
|
|
|
|
}
|
2013-02-15 10:27:48 +00:00
|
|
|
|
|
2011-11-16 15:12:00 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* Verifiy the given Latin text is not converted when using
|
|
|
|
|
|
* using the Latin variant and converted to Cyrillic when using
|
|
|
|
|
|
* the Cyrillic variant.
|
2014-04-17 18:43:42 +00:00
|
|
|
|
* @param string $text Text to convert
|
|
|
|
|
|
* @param string $msg Optional message
|
2011-11-16 15:12:00 +00:00
|
|
|
|
*/
|
2013-10-22 10:32:29 +00:00
|
|
|
|
protected function assertLatin( $text, $msg = '' ) {
|
2011-11-16 15:12:00 +00:00
|
|
|
|
$this->assertUnConverted( $text, 'sr-el', $msg );
|
|
|
|
|
|
$this->assertConverted( $text, 'sr-ec', $msg );
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Wrapper for converter::convertTo() method*/
|
2013-10-22 10:32:29 +00:00
|
|
|
|
protected function convertTo( $text, $variant ) {
|
2012-10-23 20:53:17 +00:00
|
|
|
|
return $this->getLang()
|
2011-11-16 15:12:00 +00:00
|
|
|
|
->mConverter
|
|
|
|
|
|
->convertTo(
|
2013-03-25 23:27:14 +00:00
|
|
|
|
$text, $variant
|
|
|
|
|
|
);
|
2011-11-16 15:12:00 +00:00
|
|
|
|
}
|
2013-02-15 10:27:48 +00:00
|
|
|
|
|
2013-10-22 10:32:29 +00:00
|
|
|
|
protected function convertToCyrillic( $text ) {
|
2011-11-16 15:12:00 +00:00
|
|
|
|
return $this->convertTo( $text, 'sr-ec' );
|
|
|
|
|
|
}
|
2013-02-15 10:27:48 +00:00
|
|
|
|
|
2013-10-22 10:32:29 +00:00
|
|
|
|
protected function convertToLatin( $text ) {
|
2011-11-16 15:12:00 +00:00
|
|
|
|
return $this->convertTo( $text, 'sr-el' );
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|