diff options
author | Stefan Parviainen <saparvia@caterva.eu> | 2014-12-30 19:57:12 +0100 |
---|---|---|
committer | Stefan Parviainen <saparvia@caterva.eu> | 2014-12-30 20:29:31 +0100 |
commit | 9cab8ae58a29ecf7387e6865aa170715caeabf04 (patch) | |
tree | 97c4791763ecb7c877c13b562a0ad3b80857b9d7 /library/intl/tests/LocaleResolverTest.php | |
parent | 8e034a3b6b67a9aaa20fe9db671350e198fe7c42 (diff) | |
download | volse-hubzilla-9cab8ae58a29ecf7387e6865aa170715caeabf04.tar.gz volse-hubzilla-9cab8ae58a29ecf7387e6865aa170715caeabf04.tar.bz2 volse-hubzilla-9cab8ae58a29ecf7387e6865aa170715caeabf04.zip |
Language names via intl library. Fixes #773
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'); + } +} |