MediaWiki  1.23.2
CollationTest.php
Go to the documentation of this file.
1 <?php
2 
11  protected function setUp() {
12  parent::setUp();
13  $this->checkPHPExtension( 'intl' );
14  }
15 
29  public function testIsPrefix( $lang, $base, $extended ) {
30  $cp = Collator::create( $lang );
31  $cp->setStrength( Collator::PRIMARY );
32  $baseBin = $cp->getSortKey( $base );
33  // Remove sortkey terminator
34  $baseBin = rtrim( $baseBin, "\0" );
35  $extendedBin = $cp->getSortKey( $extended );
36  $this->assertStringStartsWith( $baseBin, $extendedBin, "$base is not a prefix of $extended" );
37  }
38 
39  public static function prefixDataProvider() {
40  return array(
41  array( 'en', 'A', 'AA' ),
42  array( 'en', 'A', 'AAA' ),
43  array( 'en', 'Д', 'ДЂ' ),
44  array( 'en', 'Д', 'ДA' ),
45  // 'Ʒ' should expand to 'Z ' (note space).
46  array( 'fi', 'Z', 'Ʒ' ),
47  // 'Þ' should expand to 'th'
48  array( 'sv', 't', 'Þ' ),
49  // Javanese is a limited use alphabet, so should have 3 bytes
50  // per character, so do some tests with it.
51  array( 'en', 'ꦲ', 'ꦲꦤ' ),
52  array( 'en', 'ꦲ', 'ꦲД' ),
53  array( 'en', 'A', 'Aꦲ' ),
54  );
55  }
56 
62  public function testNotIsPrefix( $lang, $base, $extended ) {
63  $cp = Collator::create( $lang );
64  $cp->setStrength( Collator::PRIMARY );
65  $baseBin = $cp->getSortKey( $base );
66  // Remove sortkey terminator
67  $baseBin = rtrim( $baseBin, "\0" );
68  $extendedBin = $cp->getSortKey( $extended );
69  $this->assertStringStartsNotWith( $baseBin, $extendedBin, "$base is a prefix of $extended" );
70  }
71 
72  public static function notPrefixDataProvider() {
73  return array(
74  array( 'en', 'A', 'B' ),
75  array( 'en', 'AC', 'ABC' ),
76  array( 'en', 'Z', 'Ʒ' ),
77  array( 'en', 'A', 'ꦲ' ),
78  );
79  }
80 
90  public function testGetFirstLetter( $collation, $string, $firstLetter ) {
91  $col = Collation::factory( $collation );
92  $this->assertEquals( $firstLetter, $col->getFirstLetter( $string ) );
93  }
94 
95  function firstLetterProvider() {
96  return array(
97  array( 'uppercase', 'Abc', 'A' ),
98  array( 'uppercase', 'abc', 'A' ),
99  array( 'identity', 'abc', 'a' ),
100  array( 'uca-en', 'abc', 'A' ),
101  array( 'uca-en', ' ', ' ' ),
102  array( 'uca-en', 'Êveryone', 'E' ),
103  array( 'uca-vi', 'Êveryone', 'Ê' ),
104  // Make sure thorn is not a first letter.
105  array( 'uca-sv', 'The', 'T' ),
106  array( 'uca-sv', 'Å', 'Å' ),
107  array( 'uca-hu', 'dzsdo', 'Dzs' ),
108  array( 'uca-hu', 'dzdso', 'Dz' ),
109  array( 'uca-hu', 'CSD', 'Cs' ),
110  array( 'uca-root', 'CSD', 'C' ),
111  array( 'uca-fi', 'Ǥ', 'G' ),
112  array( 'uca-fi', 'Ŧ', 'T' ),
113  array( 'uca-fi', 'Ʒ', 'Z' ),
114  array( 'uca-fi', 'Ŋ', 'N' ),
115  );
116  }
117 }
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
CollationTest\prefixDataProvider
static prefixDataProvider()
Definition: CollationTest.php:39
CollationTest\firstLetterProvider
firstLetterProvider()
Definition: CollationTest.php:95
CollationTest\testGetFirstLetter
testGetFirstLetter( $collation, $string, $firstLetter)
Test correct first letter is fetched.
Definition: CollationTest.php:90
CollationTest\testNotIsPrefix
testNotIsPrefix( $lang, $base, $extended)
Opposite of testIsPrefix.
Definition: CollationTest.php:62
CollationTest\setUp
setUp()
Definition: CollationTest.php:11
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
CollationTest\testIsPrefix
testIsPrefix( $lang, $base, $extended)
Test to make sure, that if you have "X" and "XY", the binary sortkey also has "X" being a prefix of "...
Definition: CollationTest.php:29
MediaWikiLangTestCase
Base class that store and restore the Language objects.
Definition: MediaWikiLangTestCase.php:6
CollationTest
Class CollationTest @covers Collation @covers IcuCollation @covers IdentityCollation @covers Uppercas...
Definition: CollationTest.php:10
MediaWikiTestCase\checkPHPExtension
checkPHPExtension( $extName)
Check if $extName is a loaded PHP extension, will skip the test whenever it is not loaded.
Definition: MediaWikiTestCase.php:1005
Collation\factory
static factory( $collationName)
Definition: Collation.php:42
CollationTest\notPrefixDataProvider
static notPrefixDataProvider()
Definition: CollationTest.php:72