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 require_once dirname( dirname( __FILE__
) ) . '/bootstrap.php';
17 /** Tests for MediaWiki languages/LanguageUz.php */
18 class LanguageUzTest
extends MediaWikiTestCase
{
19 /* Language object. Initialized before each test */
23 $this->lang
= Language
::factory( 'uz' );
30 * @author Nikola Smolenski
32 function testConversionToCyrillic() {
33 // A convertion of Latin to Cyrillic
34 $this->assertEquals( 'абвгғ',
35 $this->convertToCyrillic( 'abvggʻ' )
37 // Same as above, but assert that -{}-s must be removed and not converted
38 $this->assertEquals( 'ljабnjвгўоdb',
39 $this->convertToCyrillic( '-{lj}-ab-{nj}-vgoʻo-{db}-' )
41 // A simple convertion of Cyrillic to Cyrillic
42 $this->assertEquals( 'абвг',
43 $this->convertToCyrillic( 'абвг' )
45 // Same as above, but assert that -{}-s must be removed and not converted
46 $this->assertEquals( 'ljабnjвгdaž',
47 $this->convertToCyrillic( '-{lj}-аб-{nj}-вг-{da}-ž' )
51 function testConversionToLatin() {
52 // A simple convertion of Latin to Latin
53 $this->assertEquals( 'abdef',
54 $this->convertToLatin( 'abdef' )
56 // A convertion of Cyrillic to Latin
57 $this->assertEquals( 'gʻabtsdOʻQyo',
58 $this->convertToLatin( 'ғабцдЎҚё' )
62 ##### HELPERS #####################################################
64 * Wrapper to verify text stay the same after applying conversion
65 * @param $text string Text to convert
66 * @param $variant string Language variant 'uz-cyrl' or 'uz-latn'
67 * @param $msg string Optional message
69 function assertUnConverted( $text, $variant, $msg = '' ) {
72 $this->convertTo( $text, $variant ),
77 * Wrapper to verify a text is different once converted to a variant.
78 * @param $text string Text to convert
79 * @param $variant string Language variant 'uz-cyrl' or 'uz-latn'
80 * @param $msg string Optional message
82 function assertConverted( $text, $variant, $msg = '' ) {
83 $this->assertNotEquals(
85 $this->convertTo( $text, $variant ),
91 * Verifiy the given Cyrillic text is not converted when using
92 * using the cyrillic variant and converted to Latin when using
95 function assertCyrillic( $text, $msg = '' ) {
96 $this->assertUnConverted( $text, 'uz-cyrl', $msg );
97 $this->assertConverted( $text, 'uz-latn', $msg );
100 * Verifiy the given Latin text is not converted when using
101 * using the Latin variant and converted to Cyrillic when using
102 * the Cyrillic variant.
104 function assertLatin( $text, $msg = '' ) {
105 $this->assertUnConverted( $text, 'uz-latn', $msg );
106 $this->assertConverted( $text, 'uz-cyrl', $msg );
110 /** Wrapper for converter::convertTo() method*/
111 function convertTo( $text, $variant ) {
112 return $this->lang
->mConverter
->convertTo( $text, $variant );
114 function convertToCyrillic( $text ) {
115 return $this->convertTo( $text, 'uz-cyrl' );
117 function convertToLatin( $text ) {
118 return $this->convertTo( $text, 'uz-latn' );