MediaWiki
REL1_20
|
00001 <?php 00015 require_once dirname( __DIR__ ) . '/bootstrap.php'; 00016 00018 class LanguageUzTest extends MediaWikiTestCase { 00019 /* Language object. Initialized before each test */ 00020 private $lang; 00021 00022 function setUp() { 00023 $this->lang = Language::factory( 'uz' ); 00024 } 00025 function tearDown() { 00026 unset( $this->lang ); 00027 } 00028 00032 function testConversionToCyrillic() { 00033 // A convertion of Latin to Cyrillic 00034 $this->assertEquals( 'абвгғ', 00035 $this->convertToCyrillic( 'abvggʻ' ) 00036 ); 00037 // Same as above, but assert that -{}-s must be removed and not converted 00038 $this->assertEquals( 'ljабnjвгўоdb', 00039 $this->convertToCyrillic( '-{lj}-ab-{nj}-vgoʻo-{db}-' ) 00040 ); 00041 // A simple convertion of Cyrillic to Cyrillic 00042 $this->assertEquals( 'абвг', 00043 $this->convertToCyrillic( 'абвг' ) 00044 ); 00045 // Same as above, but assert that -{}-s must be removed and not converted 00046 $this->assertEquals( 'ljабnjвгdaž', 00047 $this->convertToCyrillic( '-{lj}-аб-{nj}-вг-{da}-ž' ) 00048 ); 00049 } 00050 00051 function testConversionToLatin() { 00052 // A simple convertion of Latin to Latin 00053 $this->assertEquals( 'abdef', 00054 $this->convertToLatin( 'abdef' ) 00055 ); 00056 // A convertion of Cyrillic to Latin 00057 $this->assertEquals( 'gʻabtsdOʻQyo', 00058 $this->convertToLatin( 'ғабцдЎҚё' ) 00059 ); 00060 } 00061 00062 ##### HELPERS ##################################################### 00063 00069 function assertUnConverted( $text, $variant, $msg = '' ) { 00070 $this->assertEquals( 00071 $text, 00072 $this->convertTo( $text, $variant ), 00073 $msg 00074 ); 00075 } 00082 function assertConverted( $text, $variant, $msg = '' ) { 00083 $this->assertNotEquals( 00084 $text, 00085 $this->convertTo( $text, $variant ), 00086 $msg 00087 ); 00088 } 00089 00095 function assertCyrillic( $text, $msg = '' ) { 00096 $this->assertUnConverted( $text, 'uz-cyrl', $msg ); 00097 $this->assertConverted( $text, 'uz-latn', $msg ); 00098 } 00104 function assertLatin( $text, $msg = '' ) { 00105 $this->assertUnConverted( $text, 'uz-latn', $msg ); 00106 $this->assertConverted( $text, 'uz-cyrl', $msg ); 00107 } 00108 00109 00111 function convertTo( $text, $variant ) { 00112 return $this->lang->mConverter->convertTo( $text, $variant ); 00113 } 00114 function convertToCyrillic( $text ) { 00115 return $this->convertTo( $text, 'uz-cyrl' ); 00116 } 00117 function convertToLatin( $text ) { 00118 return $this->convertTo( $text, 'uz-latn' ); 00119 } 00120 }