3 * @author Ashar Voultoiz
4 * @copyright Copyright © 2011, Ashar Voultoiz
8 /** Tests for MediaWiki languages/LanguageTr.php */
9 class LanguageTrTest
extends MediaWikiTestCase
{
13 $this->lang
= Language
::factory( 'Tr' );
19 ##### Full Turkish alphabet #################################################
21 function testLowerCaseTurkishAlphabetToUppercase() {
22 $this->assertEquals( 'ABCÇDEFGĞHIİJKLMNOÖPRSŞTUÜVYZ',
23 $this->lang
->uc( 'abcçdefgğhıijklmnoöprsştuüvyz' ),
24 'Lower case Turkish alphabet to upper case'
27 function testUpperCaseTurkishAlphabetToUppercase() {
28 $this->assertEquals( 'ABCÇDEFGĞHIİJKLMNOÖPRSŞTUÜVYZ',
29 $this->lang
->uc( 'ABCÇDEFGĞHIİJKLMNOÖPRSŞTUÜVYZ' ),
30 'Upper case Turkish alphabet to upper case'
33 function testUpperCaseTurkishAlphabetToLowercase() {
34 $this->assertEquals( 'abcçdefgğhıijklmnoöprsştuüvyz',
35 $this->lang
->lc( 'ABCÇDEFGĞHIİJKLMNOÖPRSŞTUÜVYZ' ),
36 'Upper case Turkish alphabet to lower case'
39 function testLowerCaseTurkishAlphabetToLowercase() {
40 $this->assertEquals( 'abcçdefgğhıijklmnoöprsştuüvyz',
41 $this->lang
->lc( 'abcçdefgğhıijklmnoöprsştuüvyz' ),
42 'Lower case Turkish alphabet to lower case'
48 * Credits to #wikipedia-tr users berm, []LuCkY[] and Emperyan
49 * @see http://en.wikipedia.org/wiki/Dotted_and_dotless_I
50 * @dataProvider provideDottedAndDotlessI
52 function testChangeCaseOfFirstCharBeingDottedAndDotlessI( $func, $input, $inputCase, $expected ) {
53 if( $func == 'ucfirst' ) {
54 $res = $this->lang
->ucfirst( $input );
55 } elseif( $func == 'lcfirst' ) {
56 $res = $this->lang
->lcfirst( $input );
58 throw new MWException( __METHOD__
. " given an invalid function name '$func'" );
61 $msg = "Converting $inputCase case '$input' with $func should give '$expected'";
63 $this->assertEquals( $expected, $res, $msg );
66 function provideDottedAndDotlessI() {
68 # function, input, input case, expected
70 array( 'ucfirst', 'ı', 'lower', 'I' ),
71 array( 'ucfirst', 'i', 'lower', 'İ' ),
72 array( 'lcfirst', 'I', 'upper', 'ı' ),
73 array( 'lcfirst', 'İ', 'upper', 'i' ),
75 # Already using the correct case
76 array( 'ucfirst', 'I', 'upper', 'I' ),
77 array( 'ucfirst', 'İ', 'upper', 'İ' ),
78 array( 'lcfirst', 'ı', 'lower', 'ı' ),
79 array( 'lcfirst', 'i', 'lower', 'i' ),
81 # A real example taken from bug 28040 using
82 # http://tr.wikipedia.org/wiki/%C4%B0Phone
83 array( 'lcfirst', 'iPhone', 'lower', 'iPhone' ),
85 # next case is valid in Turkish but are different words if we
86 # consider IPhone is English!
87 array( 'lcfirst', 'IPhone', 'upper', 'ıPhone' ),
92 ##### LanguageTr specificities #############################################
94 * @cover LanguageTr:lc
97 function testLanguageTrLowerCasingOverride() {
98 $this->assertEquals( 'ııııı', $this->lang
->lc( 'IIIII') );
101 * @cover LanguageTr:uc
104 function testLanguageTrUpperCasingOverride() {
105 $this->assertEquals( 'İİİİİ', $this->lang
->uc( 'iiiii') );
108 ##### Upper casing a string #################################################
110 * Generic test for the Turkish dotted and dotless I strings
112 * @dataProvider provideUppercaseStringsWithDottedAndDotlessI
114 function testUpperCasingOfAStringWithDottedAndDotLessI( $expected, $input ) {
115 $this->assertEquals( $expected, $this->lang
->uc( $input ) );
117 function provideUppercaseStringsWithDottedAndDotlessI() {
119 # expected, input string to uc()
120 array( 'IIIII', 'ııııı' ),
121 array( 'IIIII', 'IIIII' ), #identity
122 array( 'İİİİİ', 'iiiii' ), # Specifically handled by LanguageTr:uc
123 array( 'İİİİİ', 'İİİİİ' ), #identity
127 ##### Lower casing a string #################################################
129 * Generic test for the Turkish dotted and dotless I strings
131 * @dataProvider provideLowercaseStringsWithDottedAndDotlessI
133 function testLowerCasingOfAStringWithDottedAndDotLessI( $expected, $input ) {
134 $this->assertEquals( $expected, $this->lang
->lc( $input ) );
136 function provideLowercaseStringsWithDottedAndDotlessI() {
138 # expected, input string to lc()
139 array( 'ııııı', 'IIIII' ), # Specifically handled by LanguageTr:lc
140 array( 'ııııı', 'ııııı' ), #identity
141 array( 'iiiii', 'İİİİİ' ),
142 array( 'iiiii', 'iiiii' ), #identity