diff options
author | Bjoern Schiessle <bjoern@schiessle.org> | 2017-11-30 12:47:55 +0100 |
---|---|---|
committer | Bjoern Schiessle <bjoern@schiessle.org> | 2017-11-30 17:29:08 +0100 |
commit | 8b734347b17da5ff2ec7f12e2149aeec785310f2 (patch) | |
tree | efb9ffc1a75037f86d03858196b3dfd5ca5f6889 /tests/lib/L10N | |
parent | 49ec86a81fa19884de125ec48325d85e2e1b1561 (diff) | |
download | nextcloud-server-8b734347b17da5ff2ec7f12e2149aeec785310f2.tar.gz nextcloud-server-8b734347b17da5ff2ec7f12e2149aeec785310f2.zip |
use formal version of German if default_language is set to 'de_DE'
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'tests/lib/L10N')
-rw-r--r-- | tests/lib/L10N/FactoryTest.php | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/tests/lib/L10N/FactoryTest.php b/tests/lib/L10N/FactoryTest.php index 171be67d336..602967b1626 100644 --- a/tests/lib/L10N/FactoryTest.php +++ b/tests/lib/L10N/FactoryTest.php @@ -368,12 +368,17 @@ class FactoryTest extends TestCase { * @param string $expected */ public function testGetLanguageFromRequest($app, $header, array $availableLanguages, $expected) { - $factory = $this->getFactory(['findAvailableLanguages']); + $factory = $this->getFactory(['findAvailableLanguages', 'respectDefaultLanguage']); $factory->expects($this->once()) ->method('findAvailableLanguages') ->with($app) ->willReturn($availableLanguages); + $factory->expects($this->any()) + ->method('respectDefaultLanguage')->willReturnCallback(function($app, $lang) { + return $lang; + }); + $this->request->expects($this->once()) ->method('getHeader') ->with('ACCEPT_LANGUAGE') @@ -497,7 +502,7 @@ class FactoryTest extends TestCase { ->with($this->equalTo('ACCEPT_LANGUAGE')) ->willReturn($browserLang); - $factory = $this->getFactory(['languageExists', 'findAvailableLanguages']); + $factory = $this->getFactory(['languageExists', 'findAvailableLanguages', 'respectDefaultLanguage']); $factory->expects($this->any()) ->method('languageExists') ->will($this->returnCallback(function ($app, $lang) use ($availableLang) { @@ -508,9 +513,44 @@ class FactoryTest extends TestCase { ->will($this->returnCallback(function ($app) use ($availableLang) { return $availableLang; })); + $factory->expects($this->any()) + ->method('respectDefaultLanguage')->willReturnCallback(function($app, $lang) { + return $lang; + }); $lang = $factory->findLanguage(null); $this->assertSame($expected, $lang); } + + public function dataTestRespectDefaultLanguage() { + return [ + ['de', 'de_DE', true, 'de_DE'], + ['de', 'de', true, 'de'], + ['de', false, true, 'de'], + ['fr', 'de_DE', true, 'fr'], + ]; + } + + /** + * test if we respect default language if possible + * + * @dataProvider dataTestRespectDefaultLanguage + * + * @param string $lang + * @param string $defaultLanguage + * @param bool $langExists + * @param string $expected + */ + public function testRespectDefaultLanguage($lang, $defaultLanguage, $langExists, $expected) { + $factory = $this->getFactory(['languageExists']); + $factory->expects($this->any()) + ->method('languageExists')->willReturn($langExists); + $this->config->expects($this->any()) + ->method('getSystemValue')->with('default_language', false)->willReturn($defaultLanguage); + + $result = $this->invokePrivate($factory, 'respectDefaultLanguage', ['app', $lang]); + $this->assertSame($expected, $result); + } + } |