diff options
author | Morris Jobke <hey@morrisjobke.de> | 2018-09-24 13:20:44 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-24 13:20:44 +0300 |
commit | 50a280338e22f34e66f03c1c069fffbf32c912b2 (patch) | |
tree | 9a4e12f1a9765d8da519f93b7b595ebcc7b3cae4 | |
parent | 67da97c3627ccc8724bd83eb5b37a4b883e8bab6 (diff) | |
parent | 2440ee6b8443c048589ab8be43a0695408a324b8 (diff) |
Merge pull request #11337 from nextcloud/feature/noid/add-test-for-11134
Add simple unit test for findLanguageFromLocale
-rw-r--r-- | tests/lib/L10N/L10nTest.php | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/lib/L10N/L10nTest.php b/tests/lib/L10N/L10nTest.php index dece334a9bd..dd0fa000b7e 100644 --- a/tests/lib/L10N/L10nTest.php +++ b/tests/lib/L10N/L10nTest.php @@ -171,4 +171,31 @@ class L10nTest extends TestCase { $l = \OC::$server->getL10N('lib', 'de'); $this->assertEquals('Mo.', $l->l('weekdayName', new \DateTime('2017-11-6'), ['width' => 'abbreviated'])); } + + /** + * @dataProvider findLanguageFromLocaleData + * @param $locale + * @param $language + */ + public function testFindLanguageFromLocale($locale, $language) { + $this->assertEquals( + $language, + \OC::$server->getL10NFactory()->findLanguageFromLocale('lib', $locale) + ); + } + + /** + * @return array + */ + public function findLanguageFromLocaleData(): array { + return [ + 'en_US' => ['en_US', 'en'], + 'en_UK' => ['en_UK', 'en'], + 'de_DE' => ['de_DE', 'de_DE'], + 'de_AT' => ['de_AT', 'de'], + 'es_EC' => ['es_EC', 'es_EC'], + 'fi_FI' => ['fi_FI', 'fi'], + 'zh_CN' => ['zh_CN', 'zh_CN'], + ]; + } } |