Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4091270
UzConverterTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
UzConverterTest.php
View Options
<?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
*
* @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.
*/
/**
* @group Language
* @covers \UzConverter
* @covers \MediaWiki\Language\LanguageConverter
*/
class
UzConverterTest
extends
MediaWikiIntegrationTestCase
{
use
LanguageConverterTestTrait
;
/**
* @author Nikola Smolenski
*/
public
function
testConversionToCyrillic
()
{
// 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}-ž'
)
);
}
public
function
testConversionToLatin
()
{
// 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
(
'ғабцдЎҚё'
)
);
}
# #### HELPERS #####################################################
/**
* Wrapper to verify text stay the same after applying conversion
* @param string $text Text to convert
* @param string $variant Language variant 'uz-cyrl' or 'uz-latn'
* @param string $msg Optional message
*/
protected
function
assertUnConverted
(
$text
,
$variant
,
$msg
=
''
)
{
$this
->
assertEquals
(
$text
,
$this
->
convertTo
(
$text
,
$variant
),
$msg
);
}
/**
* Wrapper to verify a text is different once converted to a variant.
* @param string $text Text to convert
* @param string $variant Language variant 'uz-cyrl' or 'uz-latn'
* @param string $msg Optional message
*/
protected
function
assertConverted
(
$text
,
$variant
,
$msg
=
''
)
{
$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.
* @param string $text Text to convert
* @param string $msg Optional message
*/
protected
function
assertCyrillic
(
$text
,
$msg
=
''
)
{
$this
->
assertUnConverted
(
$text
,
'uz-cyrl'
,
$msg
);
$this
->
assertConverted
(
$text
,
'uz-latn'
,
$msg
);
}
/**
* Verifiy the given Latin text is not converted when using
* using the Latin variant and converted to Cyrillic when using
* the Cyrillic variant.
* @param string $text Text to convert
* @param string $msg Optional message
*/
protected
function
assertLatin
(
$text
,
$msg
=
''
)
{
$this
->
assertUnConverted
(
$text
,
'uz-latn'
,
$msg
);
$this
->
assertConverted
(
$text
,
'uz-cyrl'
,
$msg
);
}
/**
* Wrapper for converter::convertTo() method
* @param string $text
* @param string $variant
* @return string
*/
protected
function
convertTo
(
$text
,
$variant
)
{
return
$this
->
getLanguageConverter
()->
convertTo
(
$text
,
$variant
);
}
protected
function
convertToCyrillic
(
$text
)
{
return
$this
->
convertTo
(
$text
,
'uz-cyrl'
);
}
protected
function
convertToLatin
(
$text
)
{
return
$this
->
convertTo
(
$text
,
'uz-latn'
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Aug 18 2026, 11:38 (5 w, 2 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
29/eb/3579329d0ccb29e50a1640b50cf2
Default Alt Text
UzConverterTest.php (3 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment