3 * @author Ashar Voultoiz
4 * @copyright Copyright © 2011, Ashar Voultoiz
8 require_once dirname(dirname(__FILE__
)). '/bootstrap.php';
10 /** Tests for MediaWiki languages/LanguageTr.php */
11 class LanguageTrTest
extends MediaWikiTestCase
{
15 $this->lang
= Language
::factory( 'Tr' );
21 ##### Full Turkish alphabet #################################################
23 function testLowerCaseTurkishAlphabetToUppercase() {
24 $this->assertEquals( 'ABCÇDEFGĞHIİJKLMNOÖPRSŞTUÜVYZ',
25 $this->lang
->uc( 'abcçdefgğhıijklmnoöprsştuüvyz' ),
26 'Lower case Turkish alphabet to upper case'
29 function testUpperCaseTurkishAlphabetToUppercase() {
30 $this->assertEquals( 'ABCÇDEFGĞHIİJKLMNOÖPRSŞTUÜVYZ',
31 $this->lang
->uc( 'ABCÇDEFGĞHIİJKLMNOÖPRSŞTUÜVYZ' ),
32 'Upper case Turkish alphabet to upper case'
35 function testUpperCaseTurkishAlphabetToLowercase() {
36 $this->assertEquals( 'abcçdefgğhıijklmnoöprsştuüvyz',
37 $this->lang
->lc( 'ABCÇDEFGĞHIİJKLMNOÖPRSŞTUÜVYZ' ),
38 'Upper case Turkish alphabet to lower case'
41 function testLowerCaseTurkishAlphabetToLowercase() {
42 $this->assertEquals( 'abcçdefgğhıijklmnoöprsştuüvyz',
43 $this->lang
->lc( 'abcçdefgğhıijklmnoöprsştuüvyz' ),
44 'Lower case Turkish alphabet to lower case'
50 * Credits to #wikipedia-tr users berm, []LuCkY[] and Emperyan
51 * @see http://en.wikipedia.org/wiki/Dotted_and_dotless_I
52 * @dataProvider provideDottedAndDotlessI
54 function testChangeCaseOfFirstCharBeingDottedAndDotlessI( $func, $input, $inputCase, $expected ) {
55 if( $func == 'ucfirst' ) {
56 $res = $this->lang
->ucfirst( $input );
57 } elseif( $func == 'lcfirst' ) {
58 $res = $this->lang
->lcfirst( $input );
60 throw new MWException( __METHOD__
. " given an invalid function name '$func'" );
63 $msg = "Converting $inputCase case '$input' with $func should give '$expected'";
65 $this->assertEquals( $expected, $res, $msg );
68 function provideDottedAndDotlessI() {
70 # function, input, input case, expected
72 array( 'ucfirst', 'ı', 'lower', 'I' ),
73 array( 'ucfirst', 'i', 'lower', 'İ' ),
74 array( 'lcfirst', 'I', 'upper', 'ı' ),
75 array( 'lcfirst', 'İ', 'upper', 'i' ),
77 # Already using the correct case
78 array( 'ucfirst', 'I', 'upper', 'I' ),
79 array( 'ucfirst', 'İ', 'upper', 'İ' ),
80 array( 'lcfirst', 'ı', 'lower', 'ı' ),
81 array( 'lcfirst', 'i', 'lower', 'i' ),
83 # A real example taken from bug 28040 using
84 # http://tr.wikipedia.org/wiki/%C4%B0Phone
85 array( 'lcfirst', 'iPhone', 'lower', 'iPhone' ),
87 # next case is valid in Turkish but are different words if we
88 # consider IPhone is English!
89 array( 'lcfirst', 'IPhone', 'upper', 'ıPhone' ),
94 ##### LanguageTr specificities #############################################
96 * @cover LanguageTr:lc
99 function testLanguageTrLowerCasingOverride() {
100 $this->assertEquals( 'ııııı', $this->lang
->lc( 'IIIII') );
103 * @cover LanguageTr:uc
106 function testLanguageTrUpperCasingOverride() {
107 $this->assertEquals( 'İİİİİ', $this->lang
->uc( 'iiiii') );
110 ##### Upper casing a string #################################################
112 * Generic test for the Turkish dotted and dotless I strings
114 * @dataProvider provideUppercaseStringsWithDottedAndDotlessI
116 function testUpperCasingOfAStringWithDottedAndDotLessI( $expected, $input ) {
117 $this->assertEquals( $expected, $this->lang
->uc( $input ) );
119 function provideUppercaseStringsWithDottedAndDotlessI() {
121 # expected, input string to uc()
122 array( 'IIIII', 'ııııı' ),
123 array( 'IIIII', 'IIIII' ), #identity
124 array( 'İİİİİ', 'iiiii' ), # Specifically handled by LanguageTr:uc
125 array( 'İİİİİ', 'İİİİİ' ), #identity
129 ##### Lower casing a string #################################################
131 * Generic test for the Turkish dotted and dotless I strings
133 * @dataProvider provideLowercaseStringsWithDottedAndDotlessI
135 function testLowerCasingOfAStringWithDottedAndDotLessI( $expected, $input ) {
136 $this->assertEquals( $expected, $this->lang
->lc( $input ) );
138 function provideLowercaseStringsWithDottedAndDotlessI() {
140 # expected, input string to lc()
141 array( 'ııııı', 'IIIII' ), # Specifically handled by LanguageTr:lc
142 array( 'ııııı', 'ııııı' ), #identity
143 array( 'iiiii', 'İİİİİ' ),
144 array( 'iiiii', 'iiiii' ), #identity