Fix languages empty array

Signed-off-by: GretaD <gretadoci@gmail.com>
This commit is contained in:
GretaD 2020-04-29 14:42:07 +02:00 committed by backportbot[bot]
parent 76334c4c90
commit adbdecb1d6
4 changed files with 74 additions and 49 deletions

View File

@ -146,7 +146,7 @@ abstract class AUserData extends OCSController {
$data[AccountManager::PROPERTY_WEBSITE] = $userAccount[AccountManager::PROPERTY_WEBSITE]['value']; $data[AccountManager::PROPERTY_WEBSITE] = $userAccount[AccountManager::PROPERTY_WEBSITE]['value'];
$data[AccountManager::PROPERTY_TWITTER] = $userAccount[AccountManager::PROPERTY_TWITTER]['value']; $data[AccountManager::PROPERTY_TWITTER] = $userAccount[AccountManager::PROPERTY_TWITTER]['value'];
$data['groups'] = $gids; $data['groups'] = $gids;
$data['language'] = $this->config->getUserValue($targetUserObject->getUID(), 'core', 'lang'); $data['language'] = $this->config->getSystemValue('force_language', $this->config->getUserValue($targetUserObject->getUID(), 'core', 'lang'));
$data['locale'] = $this->config->getUserValue($targetUserObject->getUID(), 'core', 'locale'); $data['locale'] = $this->config->getUserValue($targetUserObject->getUID(), 'core', 'locale');
$backend = $targetUserObject->getBackend(); $backend = $targetUserObject->getBackend();

View File

@ -225,7 +225,7 @@ class UsersControllerTest extends TestCase {
$this->assertEquals($expected, $this->api->getUsers('MyCustomSearch')->getData()); $this->assertEquals($expected, $this->api->getUsers('MyCustomSearch')->getData());
} }
public function testAddUserAlreadyExisting() { public function testAddUserAlreadyExisting() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionCode(102); $this->expectExceptionCode(102);
@ -259,7 +259,7 @@ class UsersControllerTest extends TestCase {
$this->api->addUser('AlreadyExistingUser', 'password', '', '', []); $this->api->addUser('AlreadyExistingUser', 'password', '', '', []);
} }
public function testAddUserNonExistingGroup() { public function testAddUserNonExistingGroup() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionMessage('group NonExistingGroup does not exist'); $this->expectExceptionMessage('group NonExistingGroup does not exist');
@ -295,7 +295,7 @@ class UsersControllerTest extends TestCase {
$this->api->addUser('NewUser', 'pass', '', '', ['NonExistingGroup']); $this->api->addUser('NewUser', 'pass', '', '', ['NonExistingGroup']);
} }
public function testAddUserExistingGroupNonExistingGroup() { public function testAddUserExistingGroupNonExistingGroup() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionMessage('group NonExistingGroup does not exist'); $this->expectExceptionMessage('group NonExistingGroup does not exist');
@ -487,7 +487,7 @@ class UsersControllerTest extends TestCase {
)); ));
} }
public function testAddUserFailedToGenerateUserID() { public function testAddUserFailedToGenerateUserID() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionMessage('Could not create non-existing user id'); $this->expectExceptionMessage('Could not create non-existing user id');
@ -530,7 +530,7 @@ class UsersControllerTest extends TestCase {
$this->api->addUser('', 'PasswordOfTheNewUser')->getData(); $this->api->addUser('', 'PasswordOfTheNewUser')->getData();
} }
public function testAddUserEmailRequired() { public function testAddUserEmailRequired() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionMessage('Required email address was not provided'); $this->expectExceptionMessage('Required email address was not provided');
@ -637,7 +637,7 @@ class UsersControllerTest extends TestCase {
)); ));
} }
public function testAddUserUnsuccessful() { public function testAddUserUnsuccessful() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionMessage('Bad request'); $this->expectExceptionMessage('Bad request');
@ -682,7 +682,7 @@ class UsersControllerTest extends TestCase {
$this->api->addUser('NewUser', 'PasswordOfTheNewUser'); $this->api->addUser('NewUser', 'PasswordOfTheNewUser');
} }
public function testAddUserAsSubAdminNoGroup() { public function testAddUserAsSubAdminNoGroup() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionMessage('no group specified (required for subadmins)'); $this->expectExceptionMessage('no group specified (required for subadmins)');
@ -715,7 +715,7 @@ class UsersControllerTest extends TestCase {
$this->api->addUser('NewUser', 'PasswordOfTheNewUser', '', '', []); $this->api->addUser('NewUser', 'PasswordOfTheNewUser', '', '', []);
} }
public function testAddUserAsSubAdminValidGroupNotSubAdmin() { public function testAddUserAsSubAdminValidGroupNotSubAdmin() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionMessage('insufficient privileges for group ExistingGroup'); $this->expectExceptionMessage('insufficient privileges for group ExistingGroup');
@ -858,7 +858,7 @@ class UsersControllerTest extends TestCase {
)); ));
} }
public function testGetUserTargetDoesNotExist() { public function testGetUserTargetDoesNotExist() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionMessage('User does not exist'); $this->expectExceptionMessage('User does not exist');
@ -958,6 +958,11 @@ class UsersControllerTest extends TestCase {
->method('getUserValue') ->method('getUserValue')
->with('UID', 'core', 'lang') ->with('UID', 'core', 'lang')
->willReturn('de'); ->willReturn('de');
$this->config
->expects($this->once())
->method('getSystemValue')
->with('force_language', 'de')
->willReturn('de');
$this->api $this->api
->expects($this->once()) ->expects($this->once())
->method('fillStorageInfo') ->method('fillStorageInfo')
@ -1073,6 +1078,11 @@ class UsersControllerTest extends TestCase {
->method('getUserValue') ->method('getUserValue')
->with('UID', 'core', 'enabled', 'true') ->with('UID', 'core', 'enabled', 'true')
->willReturn('true'); ->willReturn('true');
$this->config
->expects($this->once())
->method('getSystemValue')
->with('force_language', 'da')
->willReturn('da');
$this->config $this->config
->expects($this->at(1)) ->expects($this->at(1))
->method('getUserValue') ->method('getUserValue')
@ -1150,7 +1160,7 @@ class UsersControllerTest extends TestCase {
} }
public function testGetUserDataAsSubAdminAndUserIsNotAccessible() { public function testGetUserDataAsSubAdminAndUserIsNotAccessible() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionCode(997); $this->expectExceptionCode(997);
@ -1245,6 +1255,11 @@ class UsersControllerTest extends TestCase {
->method('fillStorageInfo') ->method('fillStorageInfo')
->with('UID') ->with('UID')
->willReturn(['DummyValue']); ->willReturn(['DummyValue']);
$this->config
->expects($this->once())
->method('getSystemValue')
->with('force_language', 'ru')
->willReturn('ru');
$backend = $this->createMock(UserInterface::class); $backend = $this->createMock(UserInterface::class);
$backend->expects($this->atLeastOnce()) $backend->expects($this->atLeastOnce())
@ -1384,7 +1399,7 @@ class UsersControllerTest extends TestCase {
} }
public function testEditUserRegularUserSelfEditChangeEmailInvalid() { public function testEditUserRegularUserSelfEditChangeEmailInvalid() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionCode(102); $this->expectExceptionCode(102);
@ -1453,7 +1468,7 @@ class UsersControllerTest extends TestCase {
} }
public function testEditUserRegularUserSelfEditChangeQuota() { public function testEditUserRegularUserSelfEditChangeQuota() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionCode(997); $this->expectExceptionCode(997);
@ -1518,7 +1533,7 @@ class UsersControllerTest extends TestCase {
} }
public function testEditUserAdminUserSelfEditChangeInvalidQuota() { public function testEditUserAdminUserSelfEditChangeInvalidQuota() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionMessage('Invalid quota value ABC'); $this->expectExceptionMessage('Invalid quota value ABC');
@ -1809,7 +1824,7 @@ class UsersControllerTest extends TestCase {
$this->assertEquals([], $this->api->editUser('UserToEdit', 'quota', '3042824')->getData()); $this->assertEquals([], $this->api->editUser('UserToEdit', 'quota', '3042824')->getData());
} }
public function testEditUserSubadminUserInaccessible() { public function testEditUserSubadminUserInaccessible() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionCode(997); $this->expectExceptionCode(997);
@ -1849,7 +1864,7 @@ class UsersControllerTest extends TestCase {
$this->api->editUser('UserToEdit', 'quota', 'value'); $this->api->editUser('UserToEdit', 'quota', 'value');
} }
public function testDeleteUserNotExistingUser() { public function testDeleteUserNotExistingUser() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionCode(101); $this->expectExceptionCode(101);
@ -1872,7 +1887,7 @@ class UsersControllerTest extends TestCase {
$this->api->deleteUser('UserToDelete'); $this->api->deleteUser('UserToDelete');
} }
public function testDeleteUserSelf() { public function testDeleteUserSelf() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionCode(101); $this->expectExceptionCode(101);
@ -1933,7 +1948,7 @@ class UsersControllerTest extends TestCase {
$this->assertEquals([], $this->api->deleteUser('UserToDelete')->getData()); $this->assertEquals([], $this->api->deleteUser('UserToDelete')->getData());
} }
public function testDeleteUnsuccessfulUserAsAdmin() { public function testDeleteUnsuccessfulUserAsAdmin() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionCode(101); $this->expectExceptionCode(101);
@ -2014,7 +2029,7 @@ class UsersControllerTest extends TestCase {
$this->assertEquals([], $this->api->deleteUser('UserToDelete')->getData()); $this->assertEquals([], $this->api->deleteUser('UserToDelete')->getData());
} }
public function testDeleteUnsuccessfulUserAsSubadmin() { public function testDeleteUnsuccessfulUserAsSubadmin() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionCode(101); $this->expectExceptionCode(101);
@ -2062,7 +2077,7 @@ class UsersControllerTest extends TestCase {
$this->api->deleteUser('UserToDelete'); $this->api->deleteUser('UserToDelete');
} }
public function testDeleteUserAsSubAdminAndUserIsNotAccessible() { public function testDeleteUserAsSubAdminAndUserIsNotAccessible() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionCode(997); $this->expectExceptionCode(997);
@ -2106,7 +2121,7 @@ class UsersControllerTest extends TestCase {
$this->api->deleteUser('UserToDelete'); $this->api->deleteUser('UserToDelete');
} }
public function testGetUsersGroupsTargetUserNotExisting() { public function testGetUsersGroupsTargetUserNotExisting() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionCode(998); $this->expectExceptionCode(998);
@ -2243,7 +2258,7 @@ class UsersControllerTest extends TestCase {
$this->assertEquals(['groups' => ['Group1']], $this->api->getUsersGroups('UserToLookup')->getData()); $this->assertEquals(['groups' => ['Group1']], $this->api->getUsersGroups('UserToLookup')->getData());
} }
public function testGetUsersGroupsForSubAdminUserAndUserIsInaccessible() { public function testGetUsersGroupsForSubAdminUserAndUserIsInaccessible() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionCode(997); $this->expectExceptionCode(997);
@ -2292,7 +2307,7 @@ class UsersControllerTest extends TestCase {
$this->api->getUsersGroups('UserToLookup'); $this->api->getUsersGroups('UserToLookup');
} }
public function testAddToGroupWithTargetGroupNotExisting() { public function testAddToGroupWithTargetGroupNotExisting() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionCode(102); $this->expectExceptionCode(102);
@ -2305,7 +2320,7 @@ class UsersControllerTest extends TestCase {
$this->api->addToGroup('TargetUser', 'GroupToAddTo'); $this->api->addToGroup('TargetUser', 'GroupToAddTo');
} }
public function testAddToGroupWithNoGroupSpecified() { public function testAddToGroupWithNoGroupSpecified() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionCode(101); $this->expectExceptionCode(101);
@ -2313,7 +2328,7 @@ class UsersControllerTest extends TestCase {
$this->api->addToGroup('TargetUser'); $this->api->addToGroup('TargetUser');
} }
public function testAddToGroupWithTargetUserNotExisting() { public function testAddToGroupWithTargetUserNotExisting() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionCode(103); $this->expectExceptionCode(103);
@ -2327,7 +2342,7 @@ class UsersControllerTest extends TestCase {
$this->api->addToGroup('TargetUser', 'GroupToAddTo'); $this->api->addToGroup('TargetUser', 'GroupToAddTo');
} }
public function testAddToGroupNoSubadmin() { public function testAddToGroupNoSubadmin() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionCode(104); $this->expectExceptionCode(104);
@ -2461,7 +2476,7 @@ class UsersControllerTest extends TestCase {
$this->assertEquals(new DataResponse(), $this->api->addToGroup('TargetUser', 'GroupToAddTo')); $this->assertEquals(new DataResponse(), $this->api->addToGroup('TargetUser', 'GroupToAddTo'));
} }
public function testRemoveFromGroupWithNoTargetGroup() { public function testRemoveFromGroupWithNoTargetGroup() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionCode(101); $this->expectExceptionCode(101);
@ -2475,7 +2490,7 @@ class UsersControllerTest extends TestCase {
$this->api->removeFromGroup('TargetUser', ''); $this->api->removeFromGroup('TargetUser', '');
} }
public function testRemoveFromGroupWithEmptyTargetGroup() { public function testRemoveFromGroupWithEmptyTargetGroup() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionCode(101); $this->expectExceptionCode(101);
@ -2489,7 +2504,7 @@ class UsersControllerTest extends TestCase {
$this->api->removeFromGroup('TargetUser', ''); $this->api->removeFromGroup('TargetUser', '');
} }
public function testRemoveFromGroupWithNotExistingTargetGroup() { public function testRemoveFromGroupWithNotExistingTargetGroup() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionCode(102); $this->expectExceptionCode(102);
@ -2508,7 +2523,7 @@ class UsersControllerTest extends TestCase {
$this->api->removeFromGroup('TargetUser', 'TargetGroup'); $this->api->removeFromGroup('TargetUser', 'TargetGroup');
} }
public function testRemoveFromGroupWithNotExistingTargetUser() { public function testRemoveFromGroupWithNotExistingTargetUser() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionCode(103); $this->expectExceptionCode(103);
@ -2533,7 +2548,7 @@ class UsersControllerTest extends TestCase {
$this->api->removeFromGroup('TargetUser', 'TargetGroup'); $this->api->removeFromGroup('TargetUser', 'TargetGroup');
} }
public function testRemoveFromGroupWithoutPermission() { public function testRemoveFromGroupWithoutPermission() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionCode(104); $this->expectExceptionCode(104);
@ -2574,7 +2589,7 @@ class UsersControllerTest extends TestCase {
$this->api->removeFromGroup('TargetUser', 'TargetGroup'); $this->api->removeFromGroup('TargetUser', 'TargetGroup');
} }
public function testRemoveFromGroupAsAdminFromAdmin() { public function testRemoveFromGroupAsAdminFromAdmin() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionMessage('Cannot remove yourself from the admin group'); $this->expectExceptionMessage('Cannot remove yourself from the admin group');
@ -2624,7 +2639,7 @@ class UsersControllerTest extends TestCase {
$this->api->removeFromGroup('Admin', 'admin'); $this->api->removeFromGroup('Admin', 'admin');
} }
public function testRemoveFromGroupAsSubAdminFromSubAdmin() { public function testRemoveFromGroupAsSubAdminFromSubAdmin() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionMessage('Cannot remove yourself from this group as you are a SubAdmin'); $this->expectExceptionMessage('Cannot remove yourself from this group as you are a SubAdmin');
@ -2679,7 +2694,7 @@ class UsersControllerTest extends TestCase {
$this->api->removeFromGroup('SubAdmin', 'subadmin'); $this->api->removeFromGroup('SubAdmin', 'subadmin');
} }
public function testRemoveFromGroupAsSubAdminFromLastSubAdminGroup() { public function testRemoveFromGroupAsSubAdminFromLastSubAdminGroup() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionMessage('Not viable to remove user from the last group you are SubAdmin of'); $this->expectExceptionMessage('Not viable to remove user from the last group you are SubAdmin of');
@ -2782,7 +2797,7 @@ class UsersControllerTest extends TestCase {
$this->assertEquals([], $this->api->removeFromGroup('AnotherUser', 'admin')->getData()); $this->assertEquals([], $this->api->removeFromGroup('AnotherUser', 'admin')->getData());
} }
public function testAddSubAdminWithNotExistingTargetUser() { public function testAddSubAdminWithNotExistingTargetUser() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionMessage('User does not exist'); $this->expectExceptionMessage('User does not exist');
@ -2797,7 +2812,7 @@ class UsersControllerTest extends TestCase {
$this->api->addSubAdmin('NotExistingUser', ''); $this->api->addSubAdmin('NotExistingUser', '');
} }
public function testAddSubAdminWithNotExistingTargetGroup() { public function testAddSubAdminWithNotExistingTargetGroup() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionMessage('Group does not exist'); $this->expectExceptionMessage('Group does not exist');
@ -2819,7 +2834,7 @@ class UsersControllerTest extends TestCase {
$this->api->addSubAdmin('ExistingUser', 'NotExistingGroup'); $this->api->addSubAdmin('ExistingUser', 'NotExistingGroup');
} }
public function testAddSubAdminToAdminGroup() { public function testAddSubAdminToAdminGroup() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionMessage('Cannot create subadmins for admin group'); $this->expectExceptionMessage('Cannot create subadmins for admin group');
@ -2906,7 +2921,7 @@ class UsersControllerTest extends TestCase {
$this->assertEquals([], $this->api->addSubAdmin('ExistingUser', 'TargetGroup')->getData()); $this->assertEquals([], $this->api->addSubAdmin('ExistingUser', 'TargetGroup')->getData());
} }
public function testRemoveSubAdminNotExistingTargetUser() { public function testRemoveSubAdminNotExistingTargetUser() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionMessage('User does not exist'); $this->expectExceptionMessage('User does not exist');
@ -2921,7 +2936,7 @@ class UsersControllerTest extends TestCase {
$this->api->removeSubAdmin('NotExistingUser', 'GroupToDeleteFrom'); $this->api->removeSubAdmin('NotExistingUser', 'GroupToDeleteFrom');
} }
public function testRemoveSubAdminNotExistingTargetGroup() { public function testRemoveSubAdminNotExistingTargetGroup() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionMessage('Group does not exist'); $this->expectExceptionMessage('Group does not exist');
@ -2943,7 +2958,7 @@ class UsersControllerTest extends TestCase {
} }
public function testRemoveSubAdminFromNotASubadmin() { public function testRemoveSubAdminFromNotASubadmin() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionMessage('User is not a subadmin of this group'); $this->expectExceptionMessage('User is not a subadmin of this group');
@ -3009,7 +3024,7 @@ class UsersControllerTest extends TestCase {
$this->assertEquals([], $this->api->removeSubAdmin('ExistingUser', 'GroupToDeleteFrom')->getData()); $this->assertEquals([], $this->api->removeSubAdmin('ExistingUser', 'GroupToDeleteFrom')->getData());
} }
public function testGetUserSubAdminGroupsNotExistingTargetUser() { public function testGetUserSubAdminGroupsNotExistingTargetUser() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionMessage('User does not exist'); $this->expectExceptionMessage('User does not exist');
@ -3163,7 +3178,7 @@ class UsersControllerTest extends TestCase {
$this->assertSame($expected, $api->getCurrentUser()->getData()); $this->assertSame($expected, $api->getCurrentUser()->getData());
} }
public function testGetCurrentUserNotLoggedIn() { public function testGetCurrentUserNotLoggedIn() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
@ -3216,7 +3231,7 @@ class UsersControllerTest extends TestCase {
$this->assertSame($expected, $api->getUser('uid')->getData()); $this->assertSame($expected, $api->getUser('uid')->getData());
} }
public function testResendWelcomeMessageWithNotExistingTargetUser() { public function testResendWelcomeMessageWithNotExistingTargetUser() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionCode(998); $this->expectExceptionCode(998);
@ -3230,7 +3245,7 @@ class UsersControllerTest extends TestCase {
$this->api->resendWelcomeMessage('NotExistingUser'); $this->api->resendWelcomeMessage('NotExistingUser');
} }
public function testResendWelcomeMessageAsSubAdminAndUserIsNotAccessible() { public function testResendWelcomeMessageAsSubAdminAndUserIsNotAccessible() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionCode(997); $this->expectExceptionCode(997);
@ -3275,7 +3290,7 @@ class UsersControllerTest extends TestCase {
$this->api->resendWelcomeMessage('UserToGet'); $this->api->resendWelcomeMessage('UserToGet');
} }
public function testResendWelcomeMessageNoEmail() { public function testResendWelcomeMessageNoEmail() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionMessage('Email address not available'); $this->expectExceptionMessage('Email address not available');
@ -3316,7 +3331,7 @@ class UsersControllerTest extends TestCase {
$this->api->resendWelcomeMessage('UserToGet'); $this->api->resendWelcomeMessage('UserToGet');
} }
public function testResendWelcomeMessageNullEmail() { public function testResendWelcomeMessageNullEmail() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionMessage('Email address not available'); $this->expectExceptionMessage('Email address not available');
@ -3456,7 +3471,7 @@ class UsersControllerTest extends TestCase {
$this->api->resendWelcomeMessage('UserToGet'); $this->api->resendWelcomeMessage('UserToGet');
} }
public function testResendWelcomeMessageFailed() { public function testResendWelcomeMessageFailed() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
$this->expectExceptionMessage('Sending email failed'); $this->expectExceptionMessage('Sending email failed');

View File

@ -236,6 +236,7 @@ class UsersController extends Controller {
$serverData['userCount'] = $userCount; $serverData['userCount'] = $userCount;
$serverData['languages'] = $languages; $serverData['languages'] = $languages;
$serverData['defaultLanguage'] = $this->config->getSystemValue('default_language', 'en'); $serverData['defaultLanguage'] = $this->config->getSystemValue('default_language', 'en');
$serverData['forceLanguage'] = $this->config->getSystemValue('force_language', false);
// Settings // Settings
$serverData['defaultQuota'] = $defaultQuota; $serverData['defaultQuota'] = $defaultQuota;
$serverData['canChangePassword'] = $canChangePassword; $serverData['canChangePassword'] = $canChangePassword;

View File

@ -263,7 +263,7 @@ class Factory implements IFactory {
if ($this->languageExists($app, $locale)) { if ($this->languageExists($app, $locale)) {
return $locale; return $locale;
} }
// Try to split e.g: fr_FR => fr // Try to split e.g: fr_FR => fr
$locale = explode('_', $locale)[0]; $locale = explode('_', $locale)[0];
if ($this->languageExists($app, $locale)) { if ($this->languageExists($app, $locale)) {
@ -585,7 +585,16 @@ class Factory implements IFactory {
public function getLanguages() { public function getLanguages() {
$forceLanguage = $this->config->getSystemValue('force_language', false); $forceLanguage = $this->config->getSystemValue('force_language', false);
if ($forceLanguage !== false) { if ($forceLanguage !== false) {
return []; $l = $this->get('lib', $forceLanguage);
$potentialName = (string) $l->t('__language_name__');
return [
'commonlanguages' => [[
'code' => $forceLanguage,
'name' => $potentialName,
]],
'languages' => [],
];
} }
$languageCodes = $this->findAvailableLanguages(); $languageCodes = $this->findAvailableLanguages();