summaryrefslogtreecommitdiffstats
path: root/tests/lib/L10N
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2017-04-07 10:52:17 +0200
committerJoas Schilling <coding@schilljs.com>2017-04-07 11:10:04 +0200
commit9f3d9b5b239b9ebb3ddfec1c9d2d8d2a54be8f2a (patch)
treefa0c73bf29d8211c4a48acc8f29dcf71ded3deb5 /tests/lib/L10N
parent536650c02f719cc810a0538c36113b2fa96db605 (diff)
downloadnextcloud-server-9f3d9b5b239b9ebb3ddfec1c9d2d8d2a54be8f2a.tar.gz
nextcloud-server-9f3d9b5b239b9ebb3ddfec1c9d2d8d2a54be8f2a.zip
Don't force the use of Accept-Language anymore
This is not intended anymore, since it falls back to force english when the header is not set. Also 0228bc6e66cbcb2848eacb41f1de6e7f63ebcb65 makes clear that the order should be: 1. User setting 2. Accept language 3. Admin default This is the case since the commit from above, unless via OCS and DAV. Both forced to accept-language falling back to english. By removing the force, it now also matches the w3 priority list: https://www.w3.org/International/questions/qa-lang-priorities Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests/lib/L10N')
-rw-r--r--tests/lib/L10N/FactoryTest.php48
1 files changed, 22 insertions, 26 deletions
diff --git a/tests/lib/L10N/FactoryTest.php b/tests/lib/L10N/FactoryTest.php
index 5e422758cb4..77a56b5f945 100644
--- a/tests/lib/L10N/FactoryTest.php
+++ b/tests/lib/L10N/FactoryTest.php
@@ -9,6 +9,7 @@
namespace Test\L10N;
use OC\L10N\Factory;
+use OC\L10N\LanguageNotFoundException;
use OCP\IConfig;
use OCP\IRequest;
use OCP\IUser;
@@ -339,26 +340,22 @@ class FactoryTest extends TestCase {
public function dataSetLanguageFromRequest() {
return [
// Language is available
- [null, 'de', null, ['de'], 'de', 'de'],
- [null, 'de,en', null, ['de'], 'de', 'de'],
- [null, 'de-DE,en-US;q=0.8,en;q=0.6', null, ['de'], 'de', 'de'],
+ [null, 'de', ['de'], 'de'],
+ [null, 'de,en', ['de'], 'de'],
+ [null, 'de-DE,en-US;q=0.8,en;q=0.6', ['de'], 'de'],
// Language is not available
- [null, 'de', null, ['ru'], 'en', 'en'],
- [null, 'de,en', null, ['ru', 'en'], 'en', 'en'],
- [null, 'de-DE,en-US;q=0.8,en;q=0.6', null, ['ru', 'en'], 'en', 'en'],
- // Language is available, but request language is set
- [null, 'de', 'ru', ['de'], 'de', 'ru'],
- [null, 'de,en', 'ru', ['de'], 'de', 'ru'],
- [null, 'de-DE,en-US;q=0.8,en;q=0.6', 'ru', ['de'], 'de', 'ru'],
-
- // Request lang should not be set for apps: Language is available
- ['files_pdfviewer', 'de', null, ['de'], 'de', ''],
- ['files_pdfviewer', 'de,en', null, ['de'], 'de', ''],
- ['files_pdfviewer', 'de-DE,en-US;q=0.8,en;q=0.6', null, ['de'], 'de', ''],
- // Request lang should not be set for apps: Language is not available
- ['files_pdfviewer', 'de', null, ['ru'], 'en', ''],
- ['files_pdfviewer', 'de,en', null, ['ru', 'en'], 'en', ''],
- ['files_pdfviewer', 'de-DE,en-US;q=0.8,en;q=0.6', null, ['ru', 'en'], 'en', ''],
+ [null, 'de', ['ru'], new LanguageNotFoundException()],
+ [null, 'de,en', ['ru', 'en'], 'en'],
+ [null, 'de-DE,en-US;q=0.8,en;q=0.6', ['ru', 'en'], 'en'],
+
+ // Language for app
+ ['files_pdfviewer', 'de', ['de'], 'de'],
+ ['files_pdfviewer', 'de,en', ['de'], 'de'],
+ ['files_pdfviewer', 'de-DE,en-US;q=0.8,en;q=0.6', ['de'], 'de'],
+ // Language for app is not available
+ ['files_pdfviewer', 'de', ['ru'], new LanguageNotFoundException()],
+ ['files_pdfviewer', 'de,en', ['ru', 'en'], 'en'],
+ ['files_pdfviewer', 'de-DE,en-US;q=0.8,en;q=0.6', ['ru', 'en'], 'en'],
];
}
@@ -367,12 +364,10 @@ class FactoryTest extends TestCase {
*
* @param string|null $app
* @param string $header
- * @param string|null $requestLanguage
* @param string[] $availableLanguages
* @param string $expected
- * @param string $expectedLang
*/
- public function testSetLanguageFromRequest($app, $header, $requestLanguage, array $availableLanguages, $expected, $expectedLang) {
+ public function testGetLanguageFromRequest($app, $header, array $availableLanguages, $expected) {
$factory = $this->getFactory(['findAvailableLanguages']);
$factory->expects($this->once())
->method('findAvailableLanguages')
@@ -384,11 +379,12 @@ class FactoryTest extends TestCase {
->with('ACCEPT_LANGUAGE')
->willReturn($header);
- if ($requestLanguage !== null) {
- $this->invokePrivate($factory, 'requestLanguage', [$requestLanguage]);
+ if ($expected instanceof LanguageNotFoundException) {
+ $this->setExpectedException(LanguageNotFoundException::class);
+ self::invokePrivate($factory, 'getLanguageFromRequest', [$app]);
+ } else {
+ $this->assertSame($expected, self::invokePrivate($factory, 'getLanguageFromRequest', [$app]), 'Asserting returned language');
}
- $this->assertSame($expected, $factory->setLanguageFromRequest($app), 'Asserting returned language');
- $this->assertSame($expectedLang, $this->invokePrivate($factory, 'requestLanguage'), 'Asserting stored language');
}
public function dataGetL10nFilesForApp() {