From 5b9a8f0407a9e3fe7e00f0fc9284ea986905f1b5 Mon Sep 17 00:00:00 2001 From: John Molakvoæ Date: Wed, 28 Dec 2022 15:29:54 +0100 Subject: Add component testing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ --- apps/files/lib/Controller/ApiController.php | 4 ++-- apps/files/lib/Service/UserConfig.php | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'apps/files/lib') 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'); } -- cgit v1.2.3