| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
class CustomUppercaseCollationTest extends MediaWikiIntegrationTestCase { |
| 9 |
|
| 10 |
|
| 11 |
private $collation; |
| 12 |
|
| 13 |
protected function setUp(): void { |
| 14 |
parent::setUp(); |
| 15 |
$this->collation = new CustomUppercaseCollation( |
| 16 |
$this->getServiceContainer()->getLanguageFactory(), |
| 17 |
[ |
| 18 |
'D', |
| 19 |
'C', |
| 20 |
'Cs', |
| 21 |
'B' |
| 22 |
], |
| 23 |
'en' |
| 24 |
); |
| 25 |
} |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
public function testOrder( $first, $second, $msg ) { |
| 31 |
$sortkey1 = $this->collation->getSortKey( $first ); |
| 32 |
$sortkey2 = $this->collation->getSortKey( $second ); |
| 33 |
|
| 34 |
$this->assertTrue( strcmp( $sortkey1, $sortkey2 ) < 0, $msg ); |
| 35 |
} |
| 36 |
|
| 37 |
public static function providerOrder() { |
| 38 |
return [ |
| 39 |
[ 'X', 'Z', 'Maintain order of unrearranged' ], |
| 40 |
[ 'D', 'C', 'Actually resorts' ], |
| 41 |
[ 'D', 'B', 'resort test 2' ], |
| 42 |
[ 'Adobe', 'Abode', 'not first letter' ], |
| 43 |
[ '💩 ', 'C', 'Test relocated to end' ], |
| 44 |
[ 'c', 'b', 'lowercase' ], |
| 45 |
[ 'x', 'z', 'lowercase original' ], |
| 46 |
[ 'Cz', 'Cs', 'digraphs' ], |
| 47 |
[ 'C50D', 'C100', 'Numbers' ] |
| 48 |
]; |
| 49 |
} |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
public function testGetFirstLetter( $string, $first ) { |
| 55 |
$this->assertSame( $this->collation->getFirstLetter( $string ), $first ); |
| 56 |
} |
| 57 |
|
| 58 |
public static function provideGetFirstLetter() { |
| 59 |
return [ |
| 60 |
[ 'Do', 'D' ], |
| 61 |
[ 'do', 'D' ], |
| 62 |
[ 'Ao', 'A' ], |
| 63 |
[ 'afdsa', 'A' ], |
| 64 |
[ "\u{F3000}Foo", 'D' ], |
| 65 |
[ "\u{F3001}Foo", 'C' ], |
| 66 |
[ "\u{F3002}Foo", 'Cs' ], |
| 67 |
[ "\u{F3003}Foo", 'B' ], |
| 68 |
[ "\u{F3004}Foo", "\u{F3004}" ], |
| 69 |
[ 'C', 'C' ], |
| 70 |
[ 'Cz', 'C' ], |
| 71 |
[ 'Cs', 'Cs' ], |
| 72 |
[ 'CS', 'Cs' ], |
| 73 |
[ 'cs', 'Cs' ], |
| 74 |
]; |
| 75 |
} |
| 76 |
} |