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>
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..
23 class LanguageUzTest
extends LanguageClassesTestCase
{
26 * @author Nikola Smolenski
27 * @covers LanguageConverter::convertTo
29 public function testConversionToCyrillic() {
30 // A convertion of Latin to Cyrillic
31 $this->assertEquals( 'абвгғ',
32 $this->convertToCyrillic( 'abvggʻ' )
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}-' )
38 // A simple convertion of Cyrillic to Cyrillic
39 $this->assertEquals( 'абвг',
40 $this->convertToCyrillic( 'абвг' )
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}-ž' )
49 * @covers LanguageConverter::convertTo
51 public 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 string $text Text to convert
66 * @param string $variant Language variant 'uz-cyrl' or 'uz-latn'
67 * @param string $msg Optional message
69 protected function assertUnConverted( $text, $variant, $msg = '' ) {
72 $this->convertTo( $text, $variant ),
78 * Wrapper to verify a text is different once converted to a variant.
79 * @param string $text Text to convert
80 * @param string $variant Language variant 'uz-cyrl' or 'uz-latn'
81 * @param string $msg Optional message
83 protected function assertConverted( $text, $variant, $msg = '' ) {
84 $this->assertNotEquals(
86 $this->convertTo( $text, $variant ),
92 * Verifiy the given Cyrillic text is not converted when using
93 * using the cyrillic variant and converted to Latin when using
95 * @param string $text Text to convert
96 * @param string $msg Optional message
98 protected function assertCyrillic( $text, $msg = '' ) {
99 $this->assertUnConverted( $text, 'uz-cyrl', $msg );
100 $this->assertConverted( $text, 'uz-latn', $msg );
104 * Verifiy the given Latin text is not converted when using
105 * using the Latin variant and converted to Cyrillic when using
106 * the Cyrillic variant.
107 * @param string $text Text to convert
108 * @param string $msg Optional message
110 protected function assertLatin( $text, $msg = '' ) {
111 $this->assertUnConverted( $text, 'uz-latn', $msg );
112 $this->assertConverted( $text, 'uz-cyrl', $msg );
115 /** Wrapper for converter::convertTo() method*/
116 protected function convertTo( $text, $variant ) {
117 return $this->getLang()->mConverter
->convertTo( $text, $variant );
120 protected function convertToCyrillic( $text ) {
121 return $this->convertTo( $text, 'uz-cyrl' );
124 protected function convertToLatin( $text ) {
125 return $this->convertTo( $text, 'uz-latn' );