diff options
author | John Molakvoæ <skjnldsv@protonmail.com> | 2022-12-28 15:29:54 +0100 |
---|---|---|
committer | John Molakvoæ <skjnldsv@protonmail.com> | 2023-01-04 16:46:14 +0100 |
commit | 5b9a8f0407a9e3fe7e00f0fc9284ea986905f1b5 (patch) | |
tree | 1363678dab6ed5e1554a7a74bc8a6a1a55bdf785 /apps/files/lib | |
parent | 8f1bf13ae3046400ce6248fb13e5515e8e9ed5c4 (diff) | |
download | nextcloud-server-5b9a8f0407a9e3fe7e00f0fc9284ea986905f1b5.tar.gz nextcloud-server-5b9a8f0407a9e3fe7e00f0fc9284ea986905f1b5.zip |
Add component testing
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files/lib')
-rw-r--r-- | apps/files/lib/Controller/ApiController.php | 4 | ||||
-rw-r--r-- | apps/files/lib/Service/UserConfig.php | 9 |
2 files changed, 7 insertions, 6 deletions
diff --git a/apps/files/lib/Controller/ApiController.php b/apps/files/lib/Controller/ApiController.php index e9d15018d03..76597b7a018 100644 --- a/apps/files/lib/Controller/ApiController.php +++ b/apps/files/lib/Controller/ApiController.php @@ -285,13 +285,13 @@ class ApiController extends Controller { * * @NoAdminRequired * - * @param bool $key + * @param string $key * @param string|bool $value * @return JSONResponse */ public function setConfig(string $key, string|bool $value): JSONResponse { try { - $this->userConfig->setConfig($key, $value); + $this->userConfig->setConfig($key, (string)$value); } catch (\InvalidArgumentException $e) { return new JSONResponse(['message' => $e->getMessage()], Http::STATUS_BAD_REQUEST); } diff --git a/apps/files/lib/Service/UserConfig.php b/apps/files/lib/Service/UserConfig.php index e3b863c7333..7ccf7008512 100644 --- a/apps/files/lib/Service/UserConfig.php +++ b/apps/files/lib/Service/UserConfig.php @@ -41,8 +41,9 @@ class UserConfig { ], ]; - private IConfig $config; - private IUser|null $user; + protected IConfig $config; + /** @var \OCP\IUser|null */ + protected mixed $user = null; public function __construct(IConfig $config, IUserSession $userSession) { $this->config = $config; @@ -98,7 +99,7 @@ class UserConfig { * @throws \InvalidArgumentException */ public function setConfig($key, $value) { - if (!$this->user) { + if ($this->user === null) { throw new \Exception('No user logged in'); } @@ -123,7 +124,7 @@ class UserConfig { * @return array */ public function getConfigs(): array { - if (!$this->user) { + if ($this->user === null) { throw new \Exception('No user logged in'); } |