Skip to content

Commit

Permalink
Fix Ru to En transliteration, fix code styles and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fre5h committed Feb 3, 2016
1 parent b679d6b commit f61b553
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
10 changes: 5 additions & 5 deletions src/RussianToEnglish.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ class RussianToEnglish implements TransliteratorInterface
'ч' => 'ch',
'ш' => 'sh',
'щ' => 'sht',
'ь' => '\'',
'ь' => '',
'ы' => 'y',
'ъ' => '\'',
'ъ' => '',
'ю' => 'yu',
'я' => 'ya',
'А' => 'A',
Expand Down Expand Up @@ -82,12 +82,12 @@ class RussianToEnglish implements TransliteratorInterface
'Ч' => 'Ch',
'Ш' => 'Sh',
'Щ' => 'Sht',
'Ь' => '\'',
'Ь' => '',
'Ы' => 'Y',
'Ъ' => '\'',
'Ъ' => '',
'Ю' => 'Yu',
'Я' => 'Ya',
'\'' => ''
"'" => '',
];

/**
Expand Down
2 changes: 1 addition & 1 deletion src/UkrainianToEnglish.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class UkrainianToEnglish implements TransliteratorInterface
'ь' => '',
'ю' => 'iu',
'я' => 'ia',
'\'' => ''
'\'' => '',
];

/**
Expand Down
23 changes: 14 additions & 9 deletions tests/RussianToEnglishTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
* file that was distributed with this source code.
*/
namespace Tests\Fresh\Transliteration;

use Fresh\Transliteration\Transliterator;

/**
* RussianToEnglish Transliterator Test
*
Expand All @@ -20,28 +22,31 @@ class RussianToEnglishTest extends \PHPUnit_Framework_TestCase
* @var Transliterator
*/
protected $transliterator;

/**
* Set up environment
*/
public function setUp()
{
$this->transliterator = new Transliterator();
}

/**
* Test transliteration from Russian to English
*
* @param array $russianText Russian text
* @param array $russianText Russian text
* @param array $transliteratedText Expected transliterated text
*
* @test
* @covers \Fresh\Transliteration\Transliterator
* @covers \Fresh\Transliteration\RussianToEnglish
* @covers \Fresh\Transliteration\Transliterator
* @covers \Fresh\Transliteration\RussianToEnglish
* @dataProvider dataProvider
*/
public function transliterationFromRussianToEnglish($russianText, $transliteratedText)
{
$this->assertEquals($transliteratedText, $this->transliterator->ruToEn($russianText));
}

/**
* Data provider for transliteration from Russian to English
*
Expand Down Expand Up @@ -77,10 +82,10 @@ public function dataProvider()
['ц', 'ts'],
['ч', 'ch'],
['ш', 'sh'],
['щ', 'sht'],
['ь', '\''],
['щ', 'sht'],
['ь', ''],
['ы', 'y'],
['ъ', '\''],
['ъ', ''],
['ю', 'yu'],
['я', 'ya'],
['А', 'A'],
Expand Down Expand Up @@ -109,9 +114,9 @@ public function dataProvider()
['Ч', 'Ch'],
['Ш', 'Sh'],
['Щ', 'Sht'],
['Ь', '\''],
['Ы','Y]',
['Ъ','\''],
['Ь', ''],
['Ы', 'Y'],
['Ъ', ''],
['Ю', 'Yu'],
['Я', 'Ya'],
];
Expand Down
2 changes: 1 addition & 1 deletion tests/UkrainianToEnglishTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public function dataProvider()
['Феодосія', 'Feodosiia'],
// Some text
['Добрий день', 'Dobryi den'],
['Привіт світ!', 'Pryvit svit!']
['Привіт світ!', 'Pryvit svit!'],
];
}
}

0 comments on commit f61b553

Please sign in to comment.