MediaWiki  REL1_31
LanguageUzTest.php
Go to the documentation of this file.
1 <?php
24 
29  public function testConversionToCyrillic() {
30  // A convertion of Latin to Cyrillic
31  $this->assertEquals( 'абвгғ',
32  $this->convertToCyrillic( 'abvggʻ' )
33  );
34  // Same as above, but assert that -{}-s must be removed and not converted
35  $this->assertEquals( 'ljабnjвгўоdb',
36  $this->convertToCyrillic( '-{lj}-ab-{nj}-vgoʻo-{db}-' )
37  );
38  // A simple convertion of Cyrillic to Cyrillic
39  $this->assertEquals( 'абвг',
40  $this->convertToCyrillic( 'абвг' )
41  );
42  // Same as above, but assert that -{}-s must be removed and not converted
43  $this->assertEquals( 'ljабnjвгdaž',
44  $this->convertToCyrillic( '-{lj}-аб-{nj}-вг-{da}-ž' )
45  );
46  }
47 
51  public function testConversionToLatin() {
52  // A simple convertion of Latin to Latin
53  $this->assertEquals( 'abdef',
54  $this->convertToLatin( 'abdef' )
55  );
56  // A convertion of Cyrillic to Latin
57  $this->assertEquals( 'gʻabtsdOʻQyo',
58  $this->convertToLatin( 'ғабцдЎҚё' )
59  );
60  }
61 
62  # #### HELPERS #####################################################
63 
69  protected function assertUnConverted( $text, $variant, $msg = '' ) {
70  $this->assertEquals(
71  $text,
72  $this->convertTo( $text, $variant ),
73  $msg
74  );
75  }
76 
83  protected function assertConverted( $text, $variant, $msg = '' ) {
84  $this->assertNotEquals(
85  $text,
86  $this->convertTo( $text, $variant ),
87  $msg
88  );
89  }
90 
98  protected function assertCyrillic( $text, $msg = '' ) {
99  $this->assertUnConverted( $text, 'uz-cyrl', $msg );
100  $this->assertConverted( $text, 'uz-latn', $msg );
101  }
102 
110  protected function assertLatin( $text, $msg = '' ) {
111  $this->assertUnConverted( $text, 'uz-latn', $msg );
112  $this->assertConverted( $text, 'uz-cyrl', $msg );
113  }
114 
116  protected function convertTo( $text, $variant ) {
117  return $this->getLang()->mConverter->convertTo( $text, $variant );
118  }
119 
120  protected function convertToCyrillic( $text ) {
121  return $this->convertTo( $text, 'uz-cyrl' );
122  }
123 
124  protected function convertToLatin( $text ) {
125  return $this->convertTo( $text, 'uz-latn' );
126  }
127 }
LanguageUzTest\assertCyrillic
assertCyrillic( $text, $msg='')
Verifiy the given Cyrillic text is not converted when using using the cyrillic variant and converted ...
Definition: LanguageUzTest.php:98
LanguageClassesTestCase
Helping class to run tests using a clean language instance.
Definition: LanguageClassesTestCase.php:21
LanguageClassesTestCase\getLang
getLang()
Definition: LanguageClassesTestCase.php:41
LanguageUzTest\testConversionToLatin
testConversionToLatin()
LanguageConverter::convertTo.
Definition: LanguageUzTest.php:51
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:37
LanguageUzTest\assertConverted
assertConverted( $text, $variant, $msg='')
Wrapper to verify a text is different once converted to a variant.
Definition: LanguageUzTest.php:83
LanguageUzTest\convertTo
convertTo( $text, $variant)
Wrapper for converter::convertTo() method.
Definition: LanguageUzTest.php:116
LanguageUzTest\convertToLatin
convertToLatin( $text)
Definition: LanguageUzTest.php:124
LanguageUzTest\convertToCyrillic
convertToCyrillic( $text)
Definition: LanguageUzTest.php:120
LanguageUzTest\assertUnConverted
assertUnConverted( $text, $variant, $msg='')
Wrapper to verify text stay the same after applying conversion.
Definition: LanguageUzTest.php:69
LanguageUzTest\assertLatin
assertLatin( $text, $msg='')
Verifiy the given Latin text is not converted when using using the Latin variant and converted to Cyr...
Definition: LanguageUzTest.php:110
LanguageUzTest\testConversionToCyrillic
testConversionToCyrillic()
Definition: LanguageUzTest.php:29
LanguageUzTest
LanguageUz UzConverter.
Definition: LanguageUzTest.php:23