Add collation for Abkhaz (ab)
[lhc/web/wiklou.git] / tests / phpunit / includes / collation / CustomUppercaseCollationTest.php
1 <?php
2
3 class CustomUppercaseCollationTest extends MediaWikiTestCase {
4
5 public function setUp() {
6 $this->collation = new CustomUppercaseCollation( [
7 'D',
8 'C',
9 'Cs',
10 'B'
11 ], Language::factory( 'en' ) );
12
13 parent::setUp();
14 }
15
16 /**
17 * @dataProvider providerOrder
18 */
19 public function testOrder( $first, $second, $msg ) {
20 $sortkey1 = $this->collation->getSortKey( $first );
21 $sortkey2 = $this->collation->getSortKey( $second );
22
23 $this->assertTrue( strcmp( $sortkey1, $sortkey2 ) < 0, $msg );
24 }
25
26 public function providerOrder() {
27 return [
28 [ 'X', 'Z', 'Maintain order of unrearranged' ],
29 [ 'D', 'C', 'Actually resorts' ],
30 [ 'D', 'B', 'resort test 2' ],
31 [ 'Adobe', 'Abode', 'not first letter' ],
32 [ '💩 ', 'C', 'Test relocated to end' ],
33 [ 'c', 'b', 'lowercase' ],
34 [ 'x', 'z', 'lowercase original' ],
35 [ 'Cz', 'Cs', 'digraphs' ],
36 [ 'C50D', 'C100', 'Numbers' ]
37 ];
38 }
39
40 /**
41 * @dataProvider provideGetFirstLetter
42 */
43 public function testGetFirstLetter( $string, $first ) {
44 $this->assertSame( $this->collation->getFirstLetter( $string ), $first );
45 }
46
47 public function provideGetFirstLetter() {
48 return [
49 [ 'Do', 'D' ],
50 [ 'do', 'D' ],
51 [ 'Ao', 'A' ],
52 [ 'afdsa', 'A' ],
53 [ "\xF3\xB3\x80\x80Foo", 'D' ],
54 [ "\xF3\xB3\x80\x81Foo", 'C' ],
55 [ "\xF3\xB3\x80\x82Foo", 'Cs' ],
56 [ "\xF3\xB3\x80\x83Foo", 'B' ],
57 [ "\xF3\xB3\x80\x84Foo", "\xF3\xB3\x80\x84" ],
58 [ 'C', 'C' ],
59 [ 'Cz', 'C' ],
60 [ 'Cs', 'Cs' ],
61 [ 'CS', 'Cs' ],
62 [ 'cs', 'Cs' ],
63 ];
64 }
65 }