Move ResultWrapper subclasses to Rdbms
[mediawiki.git] / tests / phpunit / languages / classes / LanguageUzTest.php
blob7ef87bf460966078794a6f00b34112d4fc6b5322
1 <?php
2 /**
3 * PHPUnit tests for the Uzbek language.
4 * The language can be represented using two scripts:
5 * - Latin (uz-latn)
6 * - Cyrillic (uz-cyrl)
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>
12 * @file
14 * @todo methods in test class should be tidied:
15 * - Should be split into separate test methods and data providers
16 * - Tests for LanguageConverter and Language should probably be separate..
19 /** Tests for MediaWiki languages/LanguageUz.php */
20 class LanguageUzTest extends LanguageClassesTestCase {
22 /**
23 * @author Nikola Smolenski
24 * @covers LanguageConverter::convertTo
26 public function testConversionToCyrillic() {
27 // A convertion of Latin to Cyrillic
28 $this->assertEquals( 'абвгғ',
29 $this->convertToCyrillic( 'abvggʻ' )
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}-' )
35 // A simple convertion of Cyrillic to Cyrillic
36 $this->assertEquals( 'абвг',
37 $this->convertToCyrillic( 'абвг' )
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}-ž' )
45 /**
46 * @covers LanguageConverter::convertTo
48 public function testConversionToLatin() {
49 // A simple convertion of Latin to Latin
50 $this->assertEquals( 'abdef',
51 $this->convertToLatin( 'abdef' )
53 // A convertion of Cyrillic to Latin
54 $this->assertEquals( 'gʻabtsdOʻQyo',
55 $this->convertToLatin( 'ғабцдЎҚё' )
59 # #### HELPERS #####################################################
60 /**
61 * Wrapper to verify text stay the same after applying conversion
62 * @param string $text Text to convert
63 * @param string $variant Language variant 'uz-cyrl' or 'uz-latn'
64 * @param string $msg Optional message
66 protected function assertUnConverted( $text, $variant, $msg = '' ) {
67 $this->assertEquals(
68 $text,
69 $this->convertTo( $text, $variant ),
70 $msg
74 /**
75 * Wrapper to verify a text is different once converted to a variant.
76 * @param string $text Text to convert
77 * @param string $variant Language variant 'uz-cyrl' or 'uz-latn'
78 * @param string $msg Optional message
80 protected function assertConverted( $text, $variant, $msg = '' ) {
81 $this->assertNotEquals(
82 $text,
83 $this->convertTo( $text, $variant ),
84 $msg
88 /**
89 * Verifiy the given Cyrillic text is not converted when using
90 * using the cyrillic variant and converted to Latin when using
91 * the Latin variant.
92 * @param string $text Text to convert
93 * @param string $msg Optional message
95 protected function assertCyrillic( $text, $msg = '' ) {
96 $this->assertUnConverted( $text, 'uz-cyrl', $msg );
97 $this->assertConverted( $text, 'uz-latn', $msg );
101 * Verifiy the given Latin text is not converted when using
102 * using the Latin variant and converted to Cyrillic when using
103 * the Cyrillic variant.
104 * @param string $text Text to convert
105 * @param string $msg Optional message
107 protected function assertLatin( $text, $msg = '' ) {
108 $this->assertUnConverted( $text, 'uz-latn', $msg );
109 $this->assertConverted( $text, 'uz-cyrl', $msg );
112 /** Wrapper for converter::convertTo() method*/
113 protected function convertTo( $text, $variant ) {
114 return $this->getLang()->mConverter->convertTo( $text, $variant );
117 protected function convertToCyrillic( $text ) {
118 return $this->convertTo( $text, 'uz-cyrl' );
121 protected function convertToLatin( $text ) {
122 return $this->convertTo( $text, 'uz-latn' );