3 * PHPUnit tests for the Uzbek language.
4 * The language can be represented using two scripts:
8 * @author Robin Pepermans
9 * @author Antoine Musso <hashar at free dot fr>
10 * @copyright Copyright © 2012, Robin Pepermans
11 * @copyright Copyright © 2011, Antoine Musso <hashar at free dot fr>
15 /** Tests for MediaWiki languages/LanguageUz.php */
16 class LanguageUzTest
extends LanguageClassesTestCase
{
19 * @author Nikola Smolenski
21 function testConversionToCyrillic() {
22 // A convertion of Latin to Cyrillic
23 $this->assertEquals( 'абвгғ',
24 $this->convertToCyrillic( 'abvggʻ' )
26 // Same as above, but assert that -{}-s must be removed and not converted
27 $this->assertEquals( 'ljабnjвгўоdb',
28 $this->convertToCyrillic( '-{lj}-ab-{nj}-vgoʻo-{db}-' )
30 // A simple convertion of Cyrillic to Cyrillic
31 $this->assertEquals( 'абвг',
32 $this->convertToCyrillic( 'абвг' )
34 // Same as above, but assert that -{}-s must be removed and not converted
35 $this->assertEquals( 'ljабnjвгdaž',
36 $this->convertToCyrillic( '-{lj}-аб-{nj}-вг-{da}-ž' )
40 function testConversionToLatin() {
41 // A simple convertion of Latin to Latin
42 $this->assertEquals( 'abdef',
43 $this->convertToLatin( 'abdef' )
45 // A convertion of Cyrillic to Latin
46 $this->assertEquals( 'gʻabtsdOʻQyo',
47 $this->convertToLatin( 'ғабцдЎҚё' )
51 ##### HELPERS #####################################################
53 * Wrapper to verify text stay the same after applying conversion
54 * @param $text string Text to convert
55 * @param $variant string Language variant 'uz-cyrl' or 'uz-latn'
56 * @param $msg string Optional message
58 function assertUnConverted( $text, $variant, $msg = '' ) {
61 $this->convertTo( $text, $variant ),
67 * Wrapper to verify a text is different once converted to a variant.
68 * @param $text string Text to convert
69 * @param $variant string Language variant 'uz-cyrl' or 'uz-latn'
70 * @param $msg string Optional message
72 function assertConverted( $text, $variant, $msg = '' ) {
73 $this->assertNotEquals(
75 $this->convertTo( $text, $variant ),
81 * Verifiy the given Cyrillic text is not converted when using
82 * using the cyrillic variant and converted to Latin when using
85 function assertCyrillic( $text, $msg = '' ) {
86 $this->assertUnConverted( $text, 'uz-cyrl', $msg );
87 $this->assertConverted( $text, 'uz-latn', $msg );
91 * Verifiy the given Latin text is not converted when using
92 * using the Latin variant and converted to Cyrillic when using
93 * the Cyrillic variant.
95 function assertLatin( $text, $msg = '' ) {
96 $this->assertUnConverted( $text, 'uz-latn', $msg );
97 $this->assertConverted( $text, 'uz-cyrl', $msg );
101 /** Wrapper for converter::convertTo() method*/
102 function convertTo( $text, $variant ) {
103 return $this->getLang()->mConverter
->convertTo( $text, $variant );
106 function convertToCyrillic( $text ) {
107 return $this->convertTo( $text, 'uz-cyrl' );
110 function convertToLatin( $text ) {
111 return $this->convertTo( $text, 'uz-latn' );