Skip to content

Commit

Permalink
Fixes yiisoft#5079: added test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
qiangxue committed Sep 18, 2014
1 parent 4a31628 commit d49957f
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/unit/framework/i18n/I18NTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,37 @@ public function testTranslate()
// fallback to just langauge code with present exact match
$this->assertEquals('Hallo Welt!', $this->i18n->translate('test', 'Hello world!', [], 'de-DE'));
}

public function testDefaultSource()
{
$i18n = new I18N([
'translations' => [
'*' => new PhpMessageSource([
'basePath' => '@yiiunit/data/i18n/messages',
'fileMap' => [
'test' => 'test.php',
'foo' => 'test.php',
],
])
]
]);

$msg = 'The dog runs fast.';

// source = target. Should be returned as is.
$this->assertEquals($msg, $i18n->translate('test', $msg, [], 'en'));

// exact match
$this->assertEquals('Der Hund rennt schnell.', $i18n->translate('test', $msg, [], 'de-DE'));
$this->assertEquals('Der Hund rennt schnell.', $i18n->translate('foo', $msg, [], 'de-DE'));
$this->assertEquals($msg, $i18n->translate('bar', $msg, [], 'de-DE'));

// fallback to just language code with absent exact match
$this->assertEquals('Собака бегает быстро.', $i18n->translate('test', $msg, [], 'ru-RU'));

// fallback to just langauge code with present exact match
$this->assertEquals('Hallo Welt!', $i18n->translate('test', 'Hello world!', [], 'de-DE'));
}

public function testTranslateParams()
{
Expand Down

0 comments on commit d49957f

Please sign in to comment.