diff options
author | Stefan Parviainen <saparvia@caterva.eu> | 2014-12-31 10:42:08 +0100 |
---|---|---|
committer | Stefan Parviainen <saparvia@caterva.eu> | 2014-12-31 10:42:08 +0100 |
commit | 7bf7f8180dbc3a89824815de3bc1e4f40857d2f6 (patch) | |
tree | 34e51239e753204989af7d82793c24bb3b304ecb /library/intl/tests/LocaleResolverTest.php | |
parent | 24a16434bccb7b41d026767f81ffe5f060d566bf (diff) | |
download | volse-hubzilla-7bf7f8180dbc3a89824815de3bc1e4f40857d2f6.tar.gz volse-hubzilla-7bf7f8180dbc3a89824815de3bc1e4f40857d2f6.tar.bz2 volse-hubzilla-7bf7f8180dbc3a89824815de3bc1e4f40857d2f6.zip |
Revert "Revert "Language names via intl library.""
This reverts commit 4f35efa0bad4ae6489b63f3eebafe6542d654094.
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'); + } +} |