MediaWiki  REL1_21
LanguageUzTest.php
Go to the documentation of this file.
00001 <?php
00015 require_once dirname( __DIR__ ) . '/bootstrap.php';
00016 
00018 class LanguageUzTest extends LanguageClassesTestCase {
00019 
00023         function testConversionToCyrillic() {
00024                 // A convertion of Latin to Cyrillic
00025                 $this->assertEquals( 'абвгғ',
00026                         $this->convertToCyrillic( 'abvggʻ' )
00027                 );
00028                 // Same as above, but assert that -{}-s must be removed and not converted
00029                 $this->assertEquals( 'ljабnjвгўоdb',
00030                         $this->convertToCyrillic( '-{lj}-ab-{nj}-vgoʻo-{db}-' )
00031                 );
00032                 // A simple convertion of Cyrillic to Cyrillic
00033                 $this->assertEquals( 'абвг',
00034                         $this->convertToCyrillic( 'абвг' )
00035                 );
00036                 // Same as above, but assert that -{}-s must be removed and not converted
00037                 $this->assertEquals( 'ljабnjвгdaž',
00038                         $this->convertToCyrillic( '-{lj}-аб-{nj}-вг-{da}-ž' )
00039                 );
00040         }
00041 
00042         function testConversionToLatin() {
00043                 // A simple convertion of Latin to Latin
00044                 $this->assertEquals( 'abdef',
00045                         $this->convertToLatin( 'abdef' )
00046                 );
00047                 // A convertion of Cyrillic to Latin
00048                 $this->assertEquals( 'gʻabtsdOʻQyo',
00049                         $this->convertToLatin( 'ғабцдЎҚё' )
00050                 );
00051         }
00052 
00053         ##### HELPERS #####################################################
00054 
00060         function assertUnConverted( $text, $variant, $msg = '' ) {
00061                 $this->assertEquals(
00062                         $text,
00063                         $this->convertTo( $text, $variant ),
00064                         $msg
00065                 );
00066         }
00067 
00074         function assertConverted( $text, $variant, $msg = '' ) {
00075                 $this->assertNotEquals(
00076                         $text,
00077                         $this->convertTo( $text, $variant ),
00078                         $msg
00079                 );
00080         }
00081 
00087         function assertCyrillic( $text, $msg = '' ) {
00088                 $this->assertUnConverted( $text, 'uz-cyrl', $msg );
00089                 $this->assertConverted( $text, 'uz-latn', $msg );
00090         }
00091 
00097         function assertLatin( $text, $msg = '' ) {
00098                 $this->assertUnConverted( $text, 'uz-latn', $msg );
00099                 $this->assertConverted( $text, 'uz-cyrl', $msg );
00100         }
00101 
00102 
00104         function convertTo( $text, $variant ) {
00105                 return $this->getLang()->mConverter->convertTo( $text, $variant );
00106         }
00107 
00108         function convertToCyrillic( $text ) {
00109                 return $this->convertTo( $text, 'uz-cyrl' );
00110         }
00111 
00112         function convertToLatin( $text ) {
00113                 return $this->convertTo( $text, 'uz-latn' );
00114         }
00115 }