test(translation): add setLocale tests

This commit is contained in:
wangyi 2019-11-12 22:44:35 +08:00
parent 8226775062
commit f12cc94a67

View File

@ -286,6 +286,25 @@ class TranslatorTest extends TestCase
$this->assertEquals('foo baz', $t->getFromJson('foo :message', ['message' => 'baz']));
}
public function testSetLocale()
{
$t = new Translator($this->getLoader(), 'en');
$this->assertEquals('en', $t->getLocale());
parallel([
function () use ($t) {
$this->assertEquals('en', $t->getLocale());
$t->setLocale('zh_CN');
$this->assertEquals('zh_CN', $t->getLocale());
},
function () use ($t) {
$this->assertEquals('en', $t->getLocale());
$t->setLocale('zh_HK');
$this->assertEquals('zh_HK', $t->getLocale());
},
]);
$this->assertEquals('en', $t->getLocale());
}
protected function getLoader()
{
return Mockery::mock(TranslatorLoaderInterface::class);