diff options
author | mrjive <mrjive@mrjive.it> | 2015-01-06 15:13:03 +0100 |
---|---|---|
committer | mrjive <mrjive@mrjive.it> | 2015-01-06 15:13:03 +0100 |
commit | b80c218606994032e76805900cb9b340ea132358 (patch) | |
tree | bf625cf4c59bf521e639018399bf1770d116a6a0 /library/intl/tests/LocaleResolverTest.php | |
parent | aa6d61d3b19cb13c30bf5a1579adefedf0cc9515 (diff) | |
parent | 3185bfe3ca131d471b8fcdc0c94abf1a114486c7 (diff) | |
download | volse-hubzilla-b80c218606994032e76805900cb9b340ea132358.tar.gz volse-hubzilla-b80c218606994032e76805900cb9b340ea132358.tar.bz2 volse-hubzilla-b80c218606994032e76805900cb9b340ea132358.zip |
Merge pull request #1 from friendica/master
test pull request
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'); + } +} |