Update Codex from v1.20.0 to v1.20.1
[mediawiki.git] / tests / phpunit / includes / language / converters / TlyConverterTest.php
blobf09368adca1a7ee3ab8420dceef7f7c367f41ebc
1 <?php
2 /**
3 * PHPUnit tests for the Talysh converter.
4 * The language can be represented using two scripts:
5 * - Latin (tly)
6 * - Cyrillic (tly-cyrl)
8 * @author Amir E. Aharoni
9 */
11 /**
12 * @group Language
13 * @covers \MediaWiki\Language\LanguageConverter
14 * @covers \TlyConverter
16 class TlyConverterTest extends MediaWikiIntegrationTestCase {
17 use LanguageConverterTestTrait;
19 public function testConversionToCyrillic() {
20 // A conversion of Latin to Cyrillic
21 $this->assertEquals(
22 'АаБбВвГгҒғДдЕеӘәЖжЗзИиЫыЈјКкЛлМмНнОоПпРрСсТтУуҮүФфХхҺһЧчҸҹШш',
23 $this->convertToCyrillic(
24 'AaBbVvQqĞğDdEeƏəJjZzİiIıYyKkLlMmNnOoPpRrSsTtUuÜüFfXxHhÇçCcŞş'
28 // A simple conversion of Cyrillic to Cyrillic
29 $this->assertEquals( 'Лик',
30 $this->convertToCyrillic( 'Лик' )
33 // Assert that -{}-s are handled correctly
34 // NB: Latin word followed by Latin word, and the second one is converted
35 $this->assertEquals( 'Lankon Осторо',
36 $this->convertToCyrillic( '-{Lankon}- Ostoro' )
39 // Assert that -{}-s are handled correctly
40 // NB: Latin word followed by Cyrillic word, and nothing is converted
41 $this->assertEquals( 'Lankon Осторо',
42 $this->convertToCyrillic( '-{Lankon}- Осторо' )
46 public function testConversionToLatin() {
47 // A conversion of Cyrillic to Latin
48 $this->assertEquals(
49 'AaBbCcÇçDdEeƏəFfĞğHhXxIıİiJjKkQqLlMmNnOoPpRrSsŞşTtUuÜüVvYyZz',
50 $this->convertToLatin(
51 'АаБбҸҹЧчДдЕеӘәФфҒғҺһХхЫыИиЖжКкГгЛлМмНнОоПпРрСсШшТтУуҮүВвЈјЗз'
55 // A simple conversion of Latin to Latin
56 $this->assertEquals( 'Lik',
57 $this->convertToLatin( 'Lik' )
60 // Assert that -{}-s are handled correctly
61 // NB: Cyrillic word followed by Cyrillic word, and the second one is converted
62 $this->assertEquals( 'Ланкон Ostoro',
63 $this->convertToLatin( '-{Ланкон}- Осторо' )
66 // Assert that -{}-s are handled correctly
67 // NB: Cyrillic word followed by Latin word, and nothing is converted
68 $this->assertEquals( 'Ланкон Ostoro',
69 $this->convertToLatin( '-{Ланкон}- Ostoro' )
73 # #### HELPERS #####################################################
75 /**
76 * Wrapper for converter::convertTo() method
77 * @param string $text
78 * @param string $variant
79 * @return string
81 protected function convertTo( $text, $variant ) {
82 return $this->getLanguageConverter()->convertTo( $text, $variant );
85 protected function convertToCyrillic( $text ) {
86 return $this->convertTo( $text, 'tly-cyrl' );
89 protected function convertToLatin( $text ) {
90 return $this->convertTo( $text, 'tly' );