Remove useless bootstrap inclusions
[lhc/web/wiklou.git] / tests / phpunit / languages / LanguageTrTest.php
1 <?php
2 /**
3 * @author Ashar Voultoiz
4 * @copyright Copyright © 2011, Ashar Voultoiz
5 * @file
6 */
7
8 /** Tests for MediaWiki languages/LanguageTr.php */
9 class LanguageTrTest extends MediaWikiTestCase {
10 private $lang;
11
12 function setUp() {
13 $this->lang = Language::factory( 'Tr' );
14 }
15 function tearDown() {
16 unset( $this->lang );
17 }
18
19 ##### Full Turkish alphabet #################################################
20
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'
25 );
26 }
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'
31 );
32 }
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'
37 );
38 }
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'
43 );
44 }
45
46 /**
47 * See @bug 28040
48 * Credits to #wikipedia-tr users berm, []LuCkY[] and Emperyan
49 * @see http://en.wikipedia.org/wiki/Dotted_and_dotless_I
50 * @dataProvider provideDottedAndDotlessI
51 */
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 );
57 } else {
58 throw new MWException( __METHOD__ . " given an invalid function name '$func'" );
59 }
60
61 $msg = "Converting $inputCase case '$input' with $func should give '$expected'";
62
63 $this->assertEquals( $expected, $res, $msg );
64 }
65
66 function provideDottedAndDotlessI() {
67 return array(
68 # function, input, input case, expected
69 # Case changed:
70 array( 'ucfirst', 'ı', 'lower', 'I' ),
71 array( 'ucfirst', 'i', 'lower', 'İ' ),
72 array( 'lcfirst', 'I', 'upper', 'ı' ),
73 array( 'lcfirst', 'İ', 'upper', 'i' ),
74
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' ),
80
81 # A real example taken from bug 28040 using
82 # http://tr.wikipedia.org/wiki/%C4%B0Phone
83 array( 'lcfirst', 'iPhone', 'lower', 'iPhone' ),
84
85 # next case is valid in Turkish but are different words if we
86 # consider IPhone is English!
87 array( 'lcfirst', 'IPhone', 'upper', 'ıPhone' ),
88
89 );
90 }
91
92 ##### LanguageTr specificities #############################################
93 /**
94 * @cover LanguageTr:lc
95 * See @bug 28040
96 */
97 function testLanguageTrLowerCasingOverride() {
98 $this->assertEquals( 'ııııı', $this->lang->lc( 'IIIII') );
99 }
100 /**
101 * @cover LanguageTr:uc
102 * See @bug 28040
103 */
104 function testLanguageTrUpperCasingOverride() {
105 $this->assertEquals( 'İİİİİ', $this->lang->uc( 'iiiii') );
106 }
107
108 ##### Upper casing a string #################################################
109 /**
110 * Generic test for the Turkish dotted and dotless I strings
111 * See @bug 28040
112 * @dataProvider provideUppercaseStringsWithDottedAndDotlessI
113 */
114 function testUpperCasingOfAStringWithDottedAndDotLessI( $expected, $input ) {
115 $this->assertEquals( $expected, $this->lang->uc( $input ) );
116 }
117 function provideUppercaseStringsWithDottedAndDotlessI() {
118 return array(
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
124 );
125 }
126
127 ##### Lower casing a string #################################################
128 /**
129 * Generic test for the Turkish dotted and dotless I strings
130 * See @bug 28040
131 * @dataProvider provideLowercaseStringsWithDottedAndDotlessI
132 */
133 function testLowerCasingOfAStringWithDottedAndDotLessI( $expected, $input ) {
134 $this->assertEquals( $expected, $this->lang->lc( $input ) );
135 }
136 function provideLowercaseStringsWithDottedAndDotlessI() {
137 return array(
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
143 );
144 }
145
146 }