2012-07-15 19:47:21 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
/**
|
|
|
|
|
|
* PHPUnit tests for the Uzbek language.
|
|
|
|
|
|
* The language can be represented using two scripts:
|
|
|
|
|
|
* - Latin (uz-latn)
|
|
|
|
|
|
* - Cyrillic (uz-cyrl)
|
|
|
|
|
|
*
|
|
|
|
|
|
* @author Robin Pepermans
|
|
|
|
|
|
* @author Antoine Musso <hashar at free dot fr>
|
|
|
|
|
|
* @copyright Copyright © 2012, Robin Pepermans
|
|
|
|
|
|
* @copyright Copyright © 2011, Antoine Musso <hashar at free dot fr>
|
|
|
|
|
|
* @file
|
2013-10-22 10:32:29 +00:00
|
|
|
|
*
|
|
|
|
|
|
* @todo methods in test class should be tidied:
|
|
|
|
|
|
* - Should be split into separate test methods and data providers
|
|
|
|
|
|
* - Tests for LanguageConverter and Language should probably be separate..
|
2012-07-15 19:47:21 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
2017-12-28 08:24:40 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* @covers LanguageUz
|
|
|
|
|
|
* @covers UzConverter
|
|
|
|
|
|
*/
|
2012-10-23 20:53:17 +00:00
|
|
|
|
class LanguageUzTest extends LanguageClassesTestCase {
|
2012-07-15 19:47:21 +00:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @author Nikola Smolenski
|
2013-10-22 10:32:29 +00:00
|
|
|
|
* @covers LanguageConverter::convertTo
|
2012-07-15 19:47:21 +00:00
|
|
|
|
*/
|
2013-10-22 10:32:29 +00:00
|
|
|
|
public function testConversionToCyrillic() {
|
2012-07-15 19:47:21 +00:00
|
|
|
|
// A convertion of Latin to Cyrillic
|
|
|
|
|
|
$this->assertEquals( 'абвгғ',
|
|
|
|
|
|
$this->convertToCyrillic( 'abvggʻ' )
|
|
|
|
|
|
);
|
|
|
|
|
|
// Same as above, but assert that -{}-s must be removed and not converted
|
|
|
|
|
|
$this->assertEquals( 'ljабnjвгўоdb',
|
|
|
|
|
|
$this->convertToCyrillic( '-{lj}-ab-{nj}-vgoʻo-{db}-' )
|
|
|
|
|
|
);
|
|
|
|
|
|
// A simple convertion of Cyrillic to Cyrillic
|
|
|
|
|
|
$this->assertEquals( 'абвг',
|
|
|
|
|
|
$this->convertToCyrillic( 'абвг' )
|
|
|
|
|
|
);
|
|
|
|
|
|
// Same as above, but assert that -{}-s must be removed and not converted
|
|
|
|
|
|
$this->assertEquals( 'ljабnjвгdaž',
|
|
|
|
|
|
$this->convertToCyrillic( '-{lj}-аб-{nj}-вг-{da}-ž' )
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2013-10-22 10:32:29 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* @covers LanguageConverter::convertTo
|
|
|
|
|
|
*/
|
|
|
|
|
|
public function testConversionToLatin() {
|
2012-07-15 19:47:21 +00:00
|
|
|
|
// A simple convertion of Latin to Latin
|
|
|
|
|
|
$this->assertEquals( 'abdef',
|
|
|
|
|
|
$this->convertToLatin( 'abdef' )
|
|
|
|
|
|
);
|
|
|
|
|
|
// A convertion of Cyrillic to Latin
|
|
|
|
|
|
$this->assertEquals( 'gʻabtsdOʻQyo',
|
|
|
|
|
|
$this->convertToLatin( 'ғабцдЎҚё' )
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2015-09-11 13:44:59 +00:00
|
|
|
|
# #### HELPERS #####################################################
|
2012-07-15 19:47:21 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* Wrapper to verify text stay the same after applying conversion
|
2014-04-17 18:43:42 +00:00
|
|
|
|
* @param string $text Text to convert
|
|
|
|
|
|
* @param string $variant Language variant 'uz-cyrl' or 'uz-latn'
|
|
|
|
|
|
* @param string $msg Optional message
|
2012-07-15 19:47:21 +00:00
|
|
|
|
*/
|
2013-10-22 10:32:29 +00:00
|
|
|
|
protected function assertUnConverted( $text, $variant, $msg = '' ) {
|
2012-07-15 19:47:21 +00:00
|
|
|
|
$this->assertEquals(
|
|
|
|
|
|
$text,
|
|
|
|
|
|
$this->convertTo( $text, $variant ),
|
|
|
|
|
|
$msg
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
2013-02-15 10:27:48 +00:00
|
|
|
|
|
2012-07-15 19:47:21 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* Wrapper to verify a text is different once converted to a variant.
|
2014-04-17 18:43:42 +00:00
|
|
|
|
* @param string $text Text to convert
|
|
|
|
|
|
* @param string $variant Language variant 'uz-cyrl' or 'uz-latn'
|
|
|
|
|
|
* @param string $msg Optional message
|
2012-07-15 19:47:21 +00:00
|
|
|
|
*/
|
2013-10-22 10:32:29 +00:00
|
|
|
|
protected function assertConverted( $text, $variant, $msg = '' ) {
|
2012-07-15 19:47:21 +00:00
|
|
|
|
$this->assertNotEquals(
|
|
|
|
|
|
$text,
|
|
|
|
|
|
$this->convertTo( $text, $variant ),
|
|
|
|
|
|
$msg
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Verifiy the given Cyrillic text is not converted when using
|
|
|
|
|
|
* using the cyrillic variant and converted to Latin when using
|
|
|
|
|
|
* the Latin variant.
|
2014-04-17 18:43:42 +00:00
|
|
|
|
* @param string $text Text to convert
|
|
|
|
|
|
* @param string $msg Optional message
|
2012-07-15 19:47:21 +00:00
|
|
|
|
*/
|
2013-10-22 10:32:29 +00:00
|
|
|
|
protected function assertCyrillic( $text, $msg = '' ) {
|
2012-07-15 19:47:21 +00:00
|
|
|
|
$this->assertUnConverted( $text, 'uz-cyrl', $msg );
|
|
|
|
|
|
$this->assertConverted( $text, 'uz-latn', $msg );
|
|
|
|
|
|
}
|
2013-02-15 10:27:48 +00:00
|
|
|
|
|
2012-07-15 19:47:21 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* Verifiy the given Latin text is not converted when using
|
|
|
|
|
|
* using the Latin variant and converted to Cyrillic when using
|
|
|
|
|
|
* the Cyrillic variant.
|
2014-04-17 18:43:42 +00:00
|
|
|
|
* @param string $text Text to convert
|
|
|
|
|
|
* @param string $msg Optional message
|
2012-07-15 19:47:21 +00:00
|
|
|
|
*/
|
2013-10-22 10:32:29 +00:00
|
|
|
|
protected function assertLatin( $text, $msg = '' ) {
|
2012-07-15 19:47:21 +00:00
|
|
|
|
$this->assertUnConverted( $text, 'uz-latn', $msg );
|
|
|
|
|
|
$this->assertConverted( $text, 'uz-cyrl', $msg );
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Wrapper for converter::convertTo() method*/
|
2013-10-22 10:32:29 +00:00
|
|
|
|
protected function convertTo( $text, $variant ) {
|
2012-10-23 20:53:17 +00:00
|
|
|
|
return $this->getLang()->mConverter->convertTo( $text, $variant );
|
2012-07-15 19:47:21 +00:00
|
|
|
|
}
|
2013-02-15 10:27:48 +00:00
|
|
|
|
|
2013-10-22 10:32:29 +00:00
|
|
|
|
protected function convertToCyrillic( $text ) {
|
2012-07-15 19:47:21 +00:00
|
|
|
|
return $this->convertTo( $text, 'uz-cyrl' );
|
|
|
|
|
|
}
|
2013-02-15 10:27:48 +00:00
|
|
|
|
|
2013-10-22 10:32:29 +00:00
|
|
|
|
protected function convertToLatin( $text ) {
|
2012-07-15 19:47:21 +00:00
|
|
|
|
return $this->convertTo( $text, 'uz-latn' );
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|