2017-04-28 04:52:49 +00:00
|
|
|
<?php
|
|
|
|
|
|
2017-12-25 03:10:14 +00:00
|
|
|
/**
|
|
|
|
|
* @covers CustomUppercaseCollation
|
|
|
|
|
*/
|
2017-04-28 04:52:49 +00:00
|
|
|
class CustomUppercaseCollationTest extends MediaWikiTestCase {
|
|
|
|
|
|
|
|
|
|
public function setUp() {
|
|
|
|
|
$this->collation = new CustomUppercaseCollation( [
|
|
|
|
|
'D',
|
|
|
|
|
'C',
|
2017-12-20 22:45:23 +00:00
|
|
|
'Cs',
|
2017-04-28 04:52:49 +00:00
|
|
|
'B'
|
|
|
|
|
], Language::factory( 'en' ) );
|
|
|
|
|
|
|
|
|
|
parent::setUp();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @dataProvider providerOrder
|
|
|
|
|
*/
|
|
|
|
|
public function testOrder( $first, $second, $msg ) {
|
|
|
|
|
$sortkey1 = $this->collation->getSortKey( $first );
|
|
|
|
|
$sortkey2 = $this->collation->getSortKey( $second );
|
|
|
|
|
|
|
|
|
|
$this->assertTrue( strcmp( $sortkey1, $sortkey2 ) < 0, $msg );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function providerOrder() {
|
|
|
|
|
return [
|
|
|
|
|
[ 'X', 'Z', 'Maintain order of unrearranged' ],
|
|
|
|
|
[ 'D', 'C', 'Actually resorts' ],
|
|
|
|
|
[ 'D', 'B', 'resort test 2' ],
|
|
|
|
|
[ 'Adobe', 'Abode', 'not first letter' ],
|
|
|
|
|
[ '💩 ', 'C', 'Test relocated to end' ],
|
|
|
|
|
[ 'c', 'b', 'lowercase' ],
|
|
|
|
|
[ 'x', 'z', 'lowercase original' ],
|
2017-12-20 22:45:23 +00:00
|
|
|
[ 'Cz', 'Cs', 'digraphs' ],
|
2017-04-28 04:52:49 +00:00
|
|
|
[ 'C50D', 'C100', 'Numbers' ]
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @dataProvider provideGetFirstLetter
|
|
|
|
|
*/
|
|
|
|
|
public function testGetFirstLetter( $string, $first ) {
|
|
|
|
|
$this->assertSame( $this->collation->getFirstLetter( $string ), $first );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function provideGetFirstLetter() {
|
|
|
|
|
return [
|
|
|
|
|
[ 'Do', 'D' ],
|
|
|
|
|
[ 'do', 'D' ],
|
|
|
|
|
[ 'Ao', 'A' ],
|
|
|
|
|
[ 'afdsa', 'A' ],
|
2017-10-07 00:26:23 +00:00
|
|
|
[ "\u{F3000}Foo", 'D' ],
|
|
|
|
|
[ "\u{F3001}Foo", 'C' ],
|
|
|
|
|
[ "\u{F3002}Foo", 'Cs' ],
|
|
|
|
|
[ "\u{F3003}Foo", 'B' ],
|
|
|
|
|
[ "\u{F3004}Foo", "\u{F3004}" ],
|
2017-12-20 22:45:23 +00:00
|
|
|
[ 'C', 'C' ],
|
|
|
|
|
[ 'Cz', 'C' ],
|
|
|
|
|
[ 'Cs', 'Cs' ],
|
|
|
|
|
[ 'CS', 'Cs' ],
|
|
|
|
|
[ 'cs', 'Cs' ],
|
2017-04-28 04:52:49 +00:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|