MediaWiki  REL1_22
LanguageUzTest.php
Go to the documentation of this file.
00001 <?php
00020 class LanguageUzTest extends LanguageClassesTestCase {
00021 
00026     public function testConversionToCyrillic() {
00027         // A convertion of Latin to Cyrillic
00028         $this->assertEquals( 'абвгғ',
00029             $this->convertToCyrillic( 'abvggʻ' )
00030         );
00031         // Same as above, but assert that -{}-s must be removed and not converted
00032         $this->assertEquals( 'ljабnjвгўоdb',
00033             $this->convertToCyrillic( '-{lj}-ab-{nj}-vgoʻo-{db}-' )
00034         );
00035         // A simple convertion of Cyrillic to Cyrillic
00036         $this->assertEquals( 'абвг',
00037             $this->convertToCyrillic( 'абвг' )
00038         );
00039         // Same as above, but assert that -{}-s must be removed and not converted
00040         $this->assertEquals( 'ljабnjвгdaž',
00041             $this->convertToCyrillic( '-{lj}-аб-{nj}-вг-{da}-ž' )
00042         );
00043     }
00044 
00048     public function testConversionToLatin() {
00049         // A simple convertion of Latin to Latin
00050         $this->assertEquals( 'abdef',
00051             $this->convertToLatin( 'abdef' )
00052         );
00053         // A convertion of Cyrillic to Latin
00054         $this->assertEquals( 'gʻabtsdOʻQyo',
00055             $this->convertToLatin( 'ғабцдЎҚё' )
00056         );
00057     }
00058 
00059     ##### HELPERS #####################################################
00060 
00066     protected function assertUnConverted( $text, $variant, $msg = '' ) {
00067         $this->assertEquals(
00068             $text,
00069             $this->convertTo( $text, $variant ),
00070             $msg
00071         );
00072     }
00073 
00080     protected function assertConverted( $text, $variant, $msg = '' ) {
00081         $this->assertNotEquals(
00082             $text,
00083             $this->convertTo( $text, $variant ),
00084             $msg
00085         );
00086     }
00087 
00093     protected function assertCyrillic( $text, $msg = '' ) {
00094         $this->assertUnConverted( $text, 'uz-cyrl', $msg );
00095         $this->assertConverted( $text, 'uz-latn', $msg );
00096     }
00097 
00103     protected function assertLatin( $text, $msg = '' ) {
00104         $this->assertUnConverted( $text, 'uz-latn', $msg );
00105         $this->assertConverted( $text, 'uz-cyrl', $msg );
00106     }
00107 
00108 
00110     protected function convertTo( $text, $variant ) {
00111         return $this->getLang()->mConverter->convertTo( $text, $variant );
00112     }
00113 
00114     protected function convertToCyrillic( $text ) {
00115         return $this->convertTo( $text, 'uz-cyrl' );
00116     }
00117 
00118     protected function convertToLatin( $text ) {
00119         return $this->convertTo( $text, 'uz-latn' );
00120     }
00121 }