MediaWiki  master
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         }
00073         function assertConverted( $text, $variant, $msg = '' ) {
00074                 $this->assertNotEquals(
00075                         $text,
00076                         $this->convertTo( $text, $variant ),
00077                         $msg
00078                 );
00079         }
00080 
00086         function assertCyrillic( $text, $msg = '' ) {
00087                 $this->assertUnConverted( $text, 'uz-cyrl', $msg );
00088                 $this->assertConverted( $text, 'uz-latn', $msg );
00089         }
00095         function assertLatin( $text, $msg = '' ) {
00096                 $this->assertUnConverted( $text, 'uz-latn', $msg );
00097                 $this->assertConverted( $text, 'uz-cyrl', $msg );
00098         }
00099 
00100 
00102         function convertTo( $text, $variant ) {
00103                 return $this->getLang()->mConverter->convertTo( $text, $variant );
00104         }
00105         function convertToCyrillic( $text ) {
00106                 return $this->convertTo( $text, 'uz-cyrl' );
00107         }
00108         function convertToLatin( $text ) {
00109                 return $this->convertTo( $text, 'uz-latn' );
00110         }
00111 }