require_once dirname( __DIR__ ) . '/bootstrap.php';
/** Tests for MediaWiki languages/LanguageSr.php */
-class LanguageSrTest extends MediaWikiTestCase {
- /* Language object. Initialized before each test */
- private $lang;
-
- protected function setUp() {
- $this->lang = Language::factory( 'sr' );
- }
- protected function tearDown() {
- unset( $this->lang );
- }
-
- ##### TESTS #######################################################
-
- function testEasyConversions( ) {
+class LanguageSrTest extends LanguageClassesTestCase {
+ function testEasyConversions() {
$this->assertCyrillic(
'шђчћжШЂЧЋЖ',
'Cyrillic guessing characters'
);
}
- /** @dataProvider providePluralFourForms */
- function testPluralFourForms( $result, $value ) {
+ /** @dataProvider providePlural */
+ function testPlural( $result, $value ) {
$forms = array( 'one', 'few', 'many', 'other' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
+ $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
+ }
+
+ /** @dataProvider providePlural */
+ function testGetPluralRuleType( $result, $value ) {
+ $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) );
}
- function providePluralFourForms() {
+ public static function providePlural() {
return array (
array( 'one', 1 ),
array( 'many', 11 ),
array( 'many', 120 ),
);
}
+
/** @dataProvider providePluralTwoForms */
function testPluralTwoForms( $result, $value ) {
- $forms = array( 'one', 'several' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
+ $forms = array( 'one', 'other' );
+ $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
}
- function providePluralTwoForms() {
- return array (
+
+ public static function providePluralTwoForms() {
+ return array(
array( 'one', 1 ),
- array( 'several', 11 ),
- array( 'several', 91 ),
- array( 'several', 121 ),
+ array( 'other', 11 ),
+ array( 'other', 91 ),
+ array( 'other', 121 ),
);
}
$msg
);
}
+
/**
* Wrapper to verify a text is different once converted to a variant.
* @param $text string Text to convert
$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
/** Wrapper for converter::convertTo() method*/
function convertTo( $text, $variant ) {
- return $this
- ->lang
+ return $this->getLang()
->mConverter
->convertTo(
- $text, $variant
- );
+ $text, $variant
+ );
}
+
function convertToCyrillic( $text ) {
return $this->convertTo( $text, 'sr-ec' );
}
+
function convertToLatin( $text ) {
return $this->convertTo( $text, 'sr-el' );
}