MediaWiki REL1_30
CustomUppercaseCollationTest.php
Go to the documentation of this file.
1<?php
2
4
5 public function setUp() {
6 $this->collation = new CustomUppercaseCollation( [
7 'D',
8 'C',
9 'B'
10 ], Language::factory( 'en' ) );
11
12 parent::setUp();
13 }
14
18 public function testOrder( $first, $second, $msg ) {
19 $sortkey1 = $this->collation->getSortKey( $first );
20 $sortkey2 = $this->collation->getSortKey( $second );
21
22 $this->assertTrue( strcmp( $sortkey1, $sortkey2 ) < 0, $msg );
23 }
24
25 public function providerOrder() {
26 return [
27 [ 'X', 'Z', 'Maintain order of unrearranged' ],
28 [ 'D', 'C', 'Actually resorts' ],
29 [ 'D', 'B', 'resort test 2' ],
30 [ 'Adobe', 'Abode', 'not first letter' ],
31 [ '💩 ', 'C', 'Test relocated to end' ],
32 [ 'c', 'b', 'lowercase' ],
33 [ 'x', 'z', 'lowercase original' ],
34 [ 'C50D', 'C100', 'Numbers' ]
35 ];
36 }
37
41 public function testGetFirstLetter( $string, $first ) {
42 $this->assertSame( $this->collation->getFirstLetter( $string ), $first );
43 }
44
45 public function provideGetFirstLetter() {
46 return [
47 [ 'Do', 'D' ],
48 [ 'do', 'D' ],
49 [ 'Ao', 'A' ],
50 [ 'afdsa', 'A' ],
51 [ "\xF3\xB3\x80\x80Foo", 'D' ],
52 [ "\xF3\xB3\x80\x81Foo", 'C' ],
53 [ "\xF3\xB3\x80\x82Foo", 'B' ],
54 [ "\xF3\xB3\x80\x83Foo", "\xF3\xB3\x80\x83" ],
55 ];
56 }
57}
testGetFirstLetter( $string, $first)
provideGetFirstLetter
testOrder( $first, $second, $msg)
providerOrder
Resort normal UTF-8 order by putting a bunch of stuff in PUA.