MediaWiki  1.29.1
LanguageUzTest.php
Go to the documentation of this file.
1 <?php
21 
26  public function testConversionToCyrillic() {
27  // A convertion of Latin to Cyrillic
28  $this->assertEquals( 'абвгғ',
29  $this->convertToCyrillic( 'abvggʻ' )
30  );
31  // Same as above, but assert that -{}-s must be removed and not converted
32  $this->assertEquals( 'ljабnjвгўоdb',
33  $this->convertToCyrillic( '-{lj}-ab-{nj}-vgoʻo-{db}-' )
34  );
35  // A simple convertion of Cyrillic to Cyrillic
36  $this->assertEquals( 'абвг',
37  $this->convertToCyrillic( 'абвг' )
38  );
39  // Same as above, but assert that -{}-s must be removed and not converted
40  $this->assertEquals( 'ljабnjвгdaž',
41  $this->convertToCyrillic( '-{lj}-аб-{nj}-вг-{da}-ž' )
42  );
43  }
44 
48  public function testConversionToLatin() {
49  // A simple convertion of Latin to Latin
50  $this->assertEquals( 'abdef',
51  $this->convertToLatin( 'abdef' )
52  );
53  // A convertion of Cyrillic to Latin
54  $this->assertEquals( 'gʻabtsdOʻQyo',
55  $this->convertToLatin( 'ғабцдЎҚё' )
56  );
57  }
58 
59  # #### HELPERS #####################################################
60 
66  protected function assertUnConverted( $text, $variant, $msg = '' ) {
67  $this->assertEquals(
68  $text,
69  $this->convertTo( $text, $variant ),
70  $msg
71  );
72  }
73 
80  protected function assertConverted( $text, $variant, $msg = '' ) {
81  $this->assertNotEquals(
82  $text,
83  $this->convertTo( $text, $variant ),
84  $msg
85  );
86  }
87 
95  protected function assertCyrillic( $text, $msg = '' ) {
96  $this->assertUnConverted( $text, 'uz-cyrl', $msg );
97  $this->assertConverted( $text, 'uz-latn', $msg );
98  }
99 
107  protected function assertLatin( $text, $msg = '' ) {
108  $this->assertUnConverted( $text, 'uz-latn', $msg );
109  $this->assertConverted( $text, 'uz-cyrl', $msg );
110  }
111 
113  protected function convertTo( $text, $variant ) {
114  return $this->getLang()->mConverter->convertTo( $text, $variant );
115  }
116 
117  protected function convertToCyrillic( $text ) {
118  return $this->convertTo( $text, 'uz-cyrl' );
119  }
120 
121  protected function convertToLatin( $text ) {
122  return $this->convertTo( $text, 'uz-latn' );
123  }
124 }
LanguageUzTest\assertCyrillic
assertCyrillic( $text, $msg='')
Verifiy the given Cyrillic text is not converted when using using the cyrillic variant and converted ...
Definition: LanguageUzTest.php:95
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:48
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:35
LanguageUzTest\assertConverted
assertConverted( $text, $variant, $msg='')
Wrapper to verify a text is different once converted to a variant.
Definition: LanguageUzTest.php:80
LanguageUzTest\convertTo
convertTo( $text, $variant)
Wrapper for converter::convertTo() method.
Definition: LanguageUzTest.php:113
LanguageUzTest\convertToLatin
convertToLatin( $text)
Definition: LanguageUzTest.php:121
LanguageUzTest\convertToCyrillic
convertToCyrillic( $text)
Definition: LanguageUzTest.php:117
LanguageUzTest\assertUnConverted
assertUnConverted( $text, $variant, $msg='')
Wrapper to verify text stay the same after applying conversion.
Definition: LanguageUzTest.php:66
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:107
LanguageUzTest\testConversionToCyrillic
testConversionToCyrillic()
Definition: LanguageUzTest.php:26
LanguageUzTest
Tests for MediaWiki languages/LanguageUz.php.
Definition: LanguageUzTest.php:20