MediaWiki REL1_32
CustomUppercaseCollationTest.php
Go to the documentation of this file.
1<?php
2
7
8 public function setUp() {
9 $this->collation = new CustomUppercaseCollation( [
10 'D',
11 'C',
12 'Cs',
13 'B'
14 ], Language::factory( 'en' ) );
15
16 parent::setUp();
17 }
18
22 public function testOrder( $first, $second, $msg ) {
23 $sortkey1 = $this->collation->getSortKey( $first );
24 $sortkey2 = $this->collation->getSortKey( $second );
25
26 $this->assertTrue( strcmp( $sortkey1, $sortkey2 ) < 0, $msg );
27 }
28
29 public function providerOrder() {
30 return [
31 [ 'X', 'Z', 'Maintain order of unrearranged' ],
32 [ 'D', 'C', 'Actually resorts' ],
33 [ 'D', 'B', 'resort test 2' ],
34 [ 'Adobe', 'Abode', 'not first letter' ],
35 [ '💩 ', 'C', 'Test relocated to end' ],
36 [ 'c', 'b', 'lowercase' ],
37 [ 'x', 'z', 'lowercase original' ],
38 [ 'Cz', 'Cs', 'digraphs' ],
39 [ 'C50D', 'C100', 'Numbers' ]
40 ];
41 }
42
46 public function testGetFirstLetter( $string, $first ) {
47 $this->assertSame( $this->collation->getFirstLetter( $string ), $first );
48 }
49
50 public function provideGetFirstLetter() {
51 return [
52 [ 'Do', 'D' ],
53 [ 'do', 'D' ],
54 [ 'Ao', 'A' ],
55 [ 'afdsa', 'A' ],
56 [ "\u{F3000}Foo", 'D' ],
57 [ "\u{F3001}Foo", 'C' ],
58 [ "\u{F3002}Foo", 'Cs' ],
59 [ "\u{F3003}Foo", 'B' ],
60 [ "\u{F3004}Foo", "\u{F3004}" ],
61 [ 'C', 'C' ],
62 [ 'Cz', 'C' ],
63 [ 'Cs', 'Cs' ],
64 [ 'CS', 'Cs' ],
65 [ 'cs', 'Cs' ],
66 ];
67 }
68}
testGetFirstLetter( $string, $first)
provideGetFirstLetter
testOrder( $first, $second, $msg)
providerOrder
Resort normal UTF-8 order by putting a bunch of stuff in PUA.