| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
class ShConverterTest extends MediaWikiIntegrationTestCase { |
| 8 |
use LanguageConverterTestTrait; |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
public function testAutoConvertToAllVariants( $result, $value ) { |
| 14 |
$this->assertEquals( $result, $this->getLanguageConverter()->autoConvertToAllVariants( $value ) ); |
| 15 |
} |
| 16 |
|
| 17 |
public static function provideAutoConvertToAllVariants() { |
| 18 |
return [ |
| 19 |
[ |
| 20 |
[ |
| 21 |
'sh-latn' => 'g', |
| 22 |
'sh-cyrl' => 'г', |
| 23 |
], |
| 24 |
'g' |
| 25 |
], |
| 26 |
[ |
| 27 |
[ |
| 28 |
'sh-latn' => 'г', |
| 29 |
'sh-cyrl' => 'г', |
| 30 |
], |
| 31 |
'г' |
| 32 |
], |
| 33 |
]; |
| 34 |
} |
| 35 |
|
| 36 |
public function testConvertTo() { |
| 37 |
$this->testConversionToLatin(); |
| 38 |
$this->testConversionToCyrillic(); |
| 39 |
} |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
public function testConversionToCyrillic() { |
| 45 |
|
| 46 |
$this->assertEquals( 'абвг', |
| 47 |
$this->convertToCyrillic( 'abvg' ) |
| 48 |
); |
| 49 |
|
| 50 |
$this->assertEquals( 'ljабnjвгdž', |
| 51 |
$this->convertToCyrillic( '-{lj}-ab-{nj}-vg-{dž}-' ) |
| 52 |
); |
| 53 |
|
| 54 |
$this->assertEquals( 'абвг', |
| 55 |
$this->convertToCyrillic( 'абвг' ) |
| 56 |
); |
| 57 |
|
| 58 |
$this->assertEquals( 'ljабnjвгdž', |
| 59 |
$this->convertToCyrillic( '-{lj}-аб-{nj}-вг-{dž}-' ) |
| 60 |
); |
| 61 |
|
| 62 |
$this->assertEquals( 'а I б II в III г IV шђжчћ', |
| 63 |
$this->convertToCyrillic( 'a I b II v III g IV šđžčć' ) |
| 64 |
); |
| 65 |
|
| 66 |
$this->assertEquals( 'Cyrillic', |
| 67 |
$this->convertToCyrillic( '-{sh-latn:Latin; sh-cyrl:Cyrillic;}-' ) |
| 68 |
); |
| 69 |
} |
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
public function testConversionToLatin() { |
| 75 |
|
| 76 |
$this->assertEquals( 'abvg', |
| 77 |
$this->convertToLatin( 'abvg' ) |
| 78 |
); |
| 79 |
|
| 80 |
$this->assertEquals( 'ljabnjvgdž', |
| 81 |
$this->convertToLatin( '-{lj}-ab-{nj}-vg-{dž}-' ) |
| 82 |
); |
| 83 |
|
| 84 |
$this->assertEquals( 'Latin', |
| 85 |
$this->convertToLatin( '-{sh-latn:Latin; sh-cyrl:Cyrillic;}-' ) |
| 86 |
); |
| 87 |
} |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
protected function convertTo( $text, $variant ) { |
| 96 |
return $this->getLanguageConverter()->convertTo( $text, $variant ); |
| 97 |
} |
| 98 |
|
| 99 |
protected function convertToCyrillic( $text ) { |
| 100 |
return $this->convertTo( $text, 'sh-cyrl' ); |
| 101 |
} |
| 102 |
|
| 103 |
protected function convertToLatin( $text ) { |
| 104 |
return $this->convertTo( $text, 'sh-latn' ); |
| 105 |
} |
| 106 |
} |