Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4096693
ShConverterTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
ShConverterTest.php
View Options
<?php
/**
* @group Language
* @covers \ShConverter
*/
class
ShConverterTest
extends
MediaWikiIntegrationTestCase
{
use
LanguageConverterTestTrait
;
/**
* @dataProvider provideAutoConvertToAllVariants
*/
public
function
testAutoConvertToAllVariants
(
$result
,
$value
)
{
$this
->
assertEquals
(
$result
,
$this
->
getLanguageConverter
()->
autoConvertToAllVariants
(
$value
)
);
}
public
static
function
provideAutoConvertToAllVariants
()
{
return
[
[
[
'sh-latn'
=>
'g'
,
'sh-cyrl'
=>
'г'
,
],
'g'
],
[
[
'sh-latn'
=>
'г'
,
'sh-cyrl'
=>
'г'
,
],
'г'
],
];
}
public
function
testConvertTo
()
{
$this
->
testConversionToLatin
();
$this
->
testConversionToCyrillic
();
}
/**
* Wrapper for testConvertTo() for Cyrillic
*/
public
function
testConversionToCyrillic
()
{
// A simple conversion of Latin to Cyrillic
$this
->
assertEquals
(
'абвг'
,
$this
->
convertToCyrillic
(
'abvg'
)
);
// Same as above, but assert that -{}-s must be removed and not converted
$this
->
assertEquals
(
'ljабnjвгdž'
,
$this
->
convertToCyrillic
(
'-{lj}-ab-{nj}-vg-{dž}-'
)
);
// A simple conversion 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вгdž'
,
$this
->
convertToCyrillic
(
'-{lj}-аб-{nj}-вг-{dž}-'
)
);
// Roman numerals are not converted
$this
->
assertEquals
(
'а I б II в III г IV шђжчћ'
,
$this
->
convertToCyrillic
(
'a I b II v III g IV šđžčć'
)
);
// Exemption for the words containing "konjug" or "konjun"
$this
->
assertEquals
(
'конјугација'
,
$this
->
convertToCyrillic
(
'konjugacija'
)
);
// Exemption for the words containing "wiki"
$this
->
assertEquals
(
'Википедија'
,
$this
->
convertToCyrillic
(
'Wikipedija'
)
);
// Manual conversion rules work
$this
->
assertEquals
(
'Cyrillic'
,
$this
->
convertToCyrillic
(
'-{sh-latn:Latin; sh-cyrl:Cyrillic;}-'
)
);
}
/**
* Wrapper for testConvertTo() for Latin
*/
public
function
testConversionToLatin
()
{
// A simple conversion of Latin to Latin
$this
->
assertEquals
(
'abvg'
,
$this
->
convertToLatin
(
'abvg'
)
);
// Same as above, but assert that -{}-s must be removed and not converted
$this
->
assertEquals
(
'ljabnjvgdž'
,
$this
->
convertToLatin
(
'-{lj}-ab-{nj}-vg-{dž}-'
)
);
// Manual conversion rules work
$this
->
assertEquals
(
'Latin'
,
$this
->
convertToLatin
(
'-{sh-latn:Latin; sh-cyrl:Cyrillic;}-'
)
);
}
/**
* 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
,
'sh-cyrl'
);
}
protected
function
convertToLatin
(
$text
)
{
return
$this
->
convertTo
(
$text
,
'sh-latn'
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, Aug 18, 14:28 (3 w, 6 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
1c/0d/9b5f0b21929e72e237a29cdea2b2
Default Alt Text
ShConverterTest.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment