diff options
author | RedMatrix <info@friendica.com> | 2015-01-01 21:23:48 +1100 |
---|---|---|
committer | RedMatrix <info@friendica.com> | 2015-01-01 21:23:48 +1100 |
commit | 93b94704878c1b66ee95987de2b24dc39163763a (patch) | |
tree | 10629014e807e94da785fcf51fcf54137c03e66c /library/intl/tests/LocaleResolverTest.php | |
parent | 26069e6ca189533152c825a96755f7ef31cb28a8 (diff) | |
parent | 127527f9e9e02adb77a282c71bdd41525c859c45 (diff) | |
download | volse-hubzilla-93b94704878c1b66ee95987de2b24dc39163763a.tar.gz volse-hubzilla-93b94704878c1b66ee95987de2b24dc39163763a.tar.bz2 volse-hubzilla-93b94704878c1b66ee95987de2b24dc39163763a.zip |
Merge pull request #800 from pafcu/lang
Language names
Diffstat (limited to 'library/intl/tests/LocaleResolverTest.php')
-rw-r--r-- | library/intl/tests/LocaleResolverTest.php | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/library/intl/tests/LocaleResolverTest.php b/library/intl/tests/LocaleResolverTest.php new file mode 100644 index 000000000..a52dea353 --- /dev/null +++ b/library/intl/tests/LocaleResolverTest.php @@ -0,0 +1,51 @@ +<?php + +namespace CommerceGuys\Intl\Tests; + +use org\bovigo\vfs\vfsStream; + +/** + * @coversDefaultClass \CommerceGuys\Intl\LocaleResolverTrait + */ +class LocaleResolverTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var DummyRepository + */ + protected $repository; + + public function setUp() + { + // Simulate the presence of various definitions. + $root = vfsStream::setup('resources'); + vfsStream::newFile('dummy/bs-Cyrl.json')->at($root)->setContent(''); + vfsStream::newFile('dummy/bs.json')->at($root)->setContent(''); + vfsStream::newFile('dummy/en.json')->at($root)->setContent(''); + + $this->repository = new DummyRepository(); + } + + /** + * @covers ::resolveLocale + * @covers ::getLocaleVariants + */ + public function testLocaleFallback() + { + $locale = $this->repository->runResolveLocale('bs-Cyrl-BA'); + $this->assertEquals('bs-Cyrl', $locale); + $locale = $this->repository->runResolveLocale('bs-Latn-BA'); + $this->assertEquals('bs', $locale); + $locale = $this->repository->runResolveLocale('de', 'en'); + $this->assertEquals('en', $locale); + } + + /** + * @covers ::resolveLocale + * @covers ::getLocaleVariants + * @expectedException \CommerceGuys\Intl\Exception\UnknownLocaleException + */ + public function testInvalidLocale() + { + $locale = $this->repository->runResolveLocale('de'); + } +} |