Add some basic unit tests for the Lang class

This commit is contained in:
Kijin Sung 2016-02-02 11:23:09 +09:00
parent 0cdaf31745
commit 474c8b0901

View file

@ -0,0 +1,34 @@
<?php
class LangTest extends \Codeception\TestCase\Test
{
public function testLang()
{
$ko = Rhymix\Framework\Lang::getInstance('ko');
$en = Rhymix\Framework\Lang::getInstance('en');
$this->assertTrue($ko instanceof Rhymix\Framework\Lang);
$this->assertTrue($en instanceof Rhymix\Framework\Lang);
$this->assertFalse($ko === $en);
$ja = Rhymix\Framework\Lang::getInstance('ja');
$jp = Rhymix\Framework\Lang::getInstance('jp');
$this->assertTrue($ja === $jp);
$this->assertEquals('도움말', $ko->get('common.help'));
$this->assertEquals('Help', $en->get('common.help'));
$this->assertEquals('도움말', $ko->help);
$this->assertEquals('Help', $en->help);
$this->assertEquals('nonexistent', $ko->get('common.nonexistent'));
$this->assertEquals('nonexistent', $ko->get('common.nonexistent', 'foo', 'bar'));
$this->assertEquals('help', $ja->help);
$ja->loadPlugin('common');
$this->assertEquals('ヘルプ', $ja->help);
$ko->foobartestlang = '%s님 안녕하세요?';
$this->assertEquals('Travis님 안녕하세요?', $ko->foobartestlang('Travis'));
$en->foobartestlang = 'Hello, %s!';
$this->assertEquals('Hello, Travis!', $en->get('foobartestlang', 'Travis'));
}
}