summaryrefslogtreecommitdiffstats
path: root/apps/provisioning_api
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2020-06-23 08:45:01 +0200
committerJoas Schilling <coding@schilljs.com>2020-07-03 10:59:43 +0200
commitdb8267db26e2e81ef4a39b424c5a8ea7bc124bfd (patch)
tree0d63e8dd40150166639f84083bfaf37cd9c52077 /apps/provisioning_api
parentb997edad105d38703351b89998444ab0828f7d05 (diff)
downloadnextcloud-server-db8267db26e2e81ef4a39b424c5a8ea7bc124bfd.tar.gz
nextcloud-server-db8267db26e2e81ef4a39b424c5a8ea7bc124bfd.zip
Use the new method everywhere
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/provisioning_api')
-rw-r--r--apps/provisioning_api/lib/Controller/AUserData.php18
-rw-r--r--apps/provisioning_api/lib/Controller/GroupsController.php17
-rw-r--r--apps/provisioning_api/lib/Controller/UsersController.php20
-rw-r--r--apps/provisioning_api/tests/Controller/GroupsControllerTest.php3
-rw-r--r--apps/provisioning_api/tests/Controller/UsersControllerTest.php57
5 files changed, 38 insertions, 77 deletions
diff --git a/apps/provisioning_api/lib/Controller/AUserData.php b/apps/provisioning_api/lib/Controller/AUserData.php
index 10d223815c3..131db91add9 100644
--- a/apps/provisioning_api/lib/Controller/AUserData.php
+++ b/apps/provisioning_api/lib/Controller/AUserData.php
@@ -44,6 +44,7 @@ use OCP\IGroupManager;
use OCP\IRequest;
use OCP\IUserManager;
use OCP\IUserSession;
+use OCP\L10N\IFactory;
use OCP\User\Backend\ISetDisplayNameBackend;
use OCP\User\Backend\ISetPasswordBackend;
@@ -59,23 +60,17 @@ abstract class AUserData extends OCSController {
protected $userSession;
/** @var AccountManager */
protected $accountManager;
+ /** @var IFactory */
+ protected $l10nFactory;
- /**
- * @param string $appName
- * @param IRequest $request
- * @param IUserManager $userManager
- * @param IConfig $config
- * @param IGroupManager $groupManager
- * @param IUserSession $userSession
- * @param AccountManager $accountManager
- */
public function __construct(string $appName,
IRequest $request,
IUserManager $userManager,
IConfig $config,
IGroupManager $groupManager,
IUserSession $userSession,
- AccountManager $accountManager) {
+ AccountManager $accountManager,
+ IFactory $l10nFactory) {
parent::__construct($appName, $request);
$this->userManager = $userManager;
@@ -83,6 +78,7 @@ abstract class AUserData extends OCSController {
$this->groupManager = $groupManager;
$this->userSession = $userSession;
$this->accountManager = $accountManager;
+ $this->l10nFactory = $l10nFactory;
}
/**
@@ -146,7 +142,7 @@ abstract class AUserData extends OCSController {
$data[AccountManager::PROPERTY_WEBSITE] = $userAccount[AccountManager::PROPERTY_WEBSITE]['value'];
$data[AccountManager::PROPERTY_TWITTER] = $userAccount[AccountManager::PROPERTY_TWITTER]['value'];
$data['groups'] = $gids;
- $data['language'] = $this->config->getSystemValue('force_language', $this->config->getUserValue($targetUserObject->getUID(), 'core', 'lang'));
+ $data['language'] = $this->l10nFactory->getUserLanguage($targetUserObject);
$data['locale'] = $this->config->getUserValue($targetUserObject->getUID(), 'core', 'locale');
$backend = $targetUserObject->getBackend();
diff --git a/apps/provisioning_api/lib/Controller/GroupsController.php b/apps/provisioning_api/lib/Controller/GroupsController.php
index ee4e7b575df..243ef8ea6be 100644
--- a/apps/provisioning_api/lib/Controller/GroupsController.php
+++ b/apps/provisioning_api/lib/Controller/GroupsController.php
@@ -47,23 +47,13 @@ use OCP\IRequest;
use OCP\IUser;
use OCP\IUserManager;
use OCP\IUserSession;
+use OCP\L10N\IFactory;
class GroupsController extends AUserData {
/** @var ILogger */
private $logger;
- /**
- * @param string $appName
- * @param IRequest $request
- * @param IUserManager $userManager
- * @param IConfig $config
- * @param IGroupManager $groupManager
- * @param IUserSession $userSession
- * @param AccountManager $accountManager
- * @param ILogger $logger
- * @param UsersController $userController
- */
public function __construct(string $appName,
IRequest $request,
IUserManager $userManager,
@@ -71,6 +61,7 @@ class GroupsController extends AUserData {
IGroupManager $groupManager,
IUserSession $userSession,
AccountManager $accountManager,
+ IFactory $l10nFactory,
ILogger $logger) {
parent::__construct($appName,
$request,
@@ -78,7 +69,9 @@ class GroupsController extends AUserData {
$config,
$groupManager,
$userSession,
- $accountManager);
+ $accountManager,
+ $l10nFactory
+ );
$this->logger = $logger;
}
diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php
index 07a1514dd1f..52a712dc848 100644
--- a/apps/provisioning_api/lib/Controller/UsersController.php
+++ b/apps/provisioning_api/lib/Controller/UsersController.php
@@ -67,7 +67,7 @@ class UsersController extends AUserData {
/** @var ILogger */
private $logger;
/** @var IFactory */
- private $l10nFactory;
+ protected $l10nFactory;
/** @var NewUserMailHelper */
private $newUserMailHelper;
/** @var FederatedFileSharingFactory */
@@ -77,21 +77,6 @@ class UsersController extends AUserData {
/** @var RemoteWipe */
private $remoteWipe;
- /**
- * @param string $appName
- * @param IRequest $request
- * @param IUserManager $userManager
- * @param IConfig $config
- * @param IAppManager $appManager
- * @param IGroupManager $groupManager
- * @param IUserSession $userSession
- * @param AccountManager $accountManager
- * @param ILogger $logger
- * @param IFactory $l10nFactory
- * @param NewUserMailHelper $newUserMailHelper
- * @param FederatedFileSharingFactory $federatedFileSharingFactory
- * @param ISecureRandom $secureRandom
- */
public function __construct(string $appName,
IRequest $request,
IUserManager $userManager,
@@ -112,7 +97,8 @@ class UsersController extends AUserData {
$config,
$groupManager,
$userSession,
- $accountManager);
+ $accountManager,
+ $l10nFactory);
$this->appManager = $appManager;
$this->logger = $logger;
diff --git a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php
index 3496d445ad1..367a54465bc 100644
--- a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php
+++ b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php
@@ -41,6 +41,7 @@ use OCP\IRequest;
use OCP\IUser;
use OCP\IUserManager;
use OCP\IUserSession;
+use OCP\L10N\IFactory;
use OCP\UserInterface;
class GroupsControllerTest extends \Test\TestCase {
@@ -75,6 +76,7 @@ class GroupsControllerTest extends \Test\TestCase {
$this->groupManager = $this->createMock(Manager::class);
$this->userSession = $this->createMock(IUserSession::class);
$this->accountManager = $this->createMock(AccountManager::class);
+ $this->l10nFactory = $this->createMock(IFactory::class);
$this->logger = $this->createMock(ILogger::class);
$this->subAdminManager = $this->createMock(SubAdmin::class);
@@ -92,6 +94,7 @@ class GroupsControllerTest extends \Test\TestCase {
$this->groupManager,
$this->userSession,
$this->accountManager,
+ $this->l10nFactory,
$this->logger
])
->setMethods(['fillStorageInfo'])
diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php
index afd7304622b..f001611cebe 100644
--- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php
+++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php
@@ -953,16 +953,6 @@ class UsersControllerTest extends TestCase {
->method('getUserValue')
->with('UID', 'core', 'enabled', 'true')
->willReturn('true');
- $this->config
- ->expects($this->at(1))
- ->method('getUserValue')
- ->with('UID', 'core', 'lang')
- ->willReturn('de');
- $this->config
- ->expects($this->once())
- ->method('getSystemValue')
- ->with('force_language', 'de')
- ->willReturn('de');
$this->api
->expects($this->once())
->method('fillStorageInfo')
@@ -995,10 +985,15 @@ class UsersControllerTest extends TestCase {
->method('getBackend')
->willReturn($backend);
$targetUser
- ->expects($this->exactly(6))
->method('getUID')
->willReturn('UID');
+ $this->l10nFactory
+ ->expects($this->once())
+ ->method('getUserLanguage')
+ ->with($targetUser)
+ ->willReturn('de');
+
$expected = [
'id' => 'UID',
'enabled' => true,
@@ -1078,16 +1073,6 @@ class UsersControllerTest extends TestCase {
->method('getUserValue')
->with('UID', 'core', 'enabled', 'true')
->willReturn('true');
- $this->config
- ->expects($this->once())
- ->method('getSystemValue')
- ->with('force_language', 'da')
- ->willReturn('da');
- $this->config
- ->expects($this->at(1))
- ->method('getUserValue')
- ->with('UID', 'core', 'lang')
- ->willReturn('da');
$this->api
->expects($this->once())
->method('fillStorageInfo')
@@ -1120,7 +1105,6 @@ class UsersControllerTest extends TestCase {
->method('getBackend')
->willReturn($backend);
$targetUser
- ->expects($this->exactly(6))
->method('getUID')
->willReturn('UID');
$this->accountManager->expects($this->any())->method('getUser')
@@ -1134,6 +1118,12 @@ class UsersControllerTest extends TestCase {
]
);
+ $this->l10nFactory
+ ->expects($this->once())
+ ->method('getUserLanguage')
+ ->with($targetUser)
+ ->willReturn('da');
+
$expected = [
'id' => 'UID',
'enabled' => true,
@@ -1255,11 +1245,6 @@ class UsersControllerTest extends TestCase {
->method('fillStorageInfo')
->with('UID')
->willReturn(['DummyValue']);
- $this->config
- ->expects($this->once())
- ->method('getSystemValue')
- ->with('force_language', 'ru')
- ->willReturn('ru');
$backend = $this->createMock(UserInterface::class);
$backend->expects($this->atLeastOnce())
@@ -1275,7 +1260,6 @@ class UsersControllerTest extends TestCase {
->method('getEMailAddress')
->willReturn('subadmin@nextcloud.com');
$targetUser
- ->expects($this->exactly(6))
->method('getUID')
->willReturn('UID');
$targetUser
@@ -1294,11 +1278,6 @@ class UsersControllerTest extends TestCase {
->expects($this->once())
->method('getBackend')
->willReturn($backend);
- $this->config
- ->expects($this->at(0))
- ->method('getUserValue')
- ->with('UID', 'core', 'lang')
- ->willReturn('ru');
$this->accountManager->expects($this->any())->method('getUser')
->with($targetUser)
->willReturn(
@@ -1310,6 +1289,12 @@ class UsersControllerTest extends TestCase {
]
);
+ $this->l10nFactory
+ ->expects($this->once())
+ ->method('getUserLanguage')
+ ->with($targetUser)
+ ->willReturn('ru');
+
$expected = [
'id' => 'UID',
'storageLocation' => '/var/www/newtcloud/data/UID',
@@ -2911,8 +2896,7 @@ class UsersControllerTest extends TestCase {
$subAdminManager
->expects($this->once())
->method('createSubAdmin')
- ->with($targetUser, $targetGroup)
- ->willReturn(true);
+ ->with($targetUser, $targetGroup);
$this->groupManager
->expects($this->once())
->method('getSubAdmin')
@@ -3014,8 +2998,7 @@ class UsersControllerTest extends TestCase {
$subAdminManager
->expects($this->once())
->method('deleteSubAdmin')
- ->with($targetUser, $targetGroup)
- ->willReturn(true);
+ ->with($targetUser, $targetGroup);
$this->groupManager
->expects($this->once())
->method('getSubAdmin')