Skip to content

Commit d6a6f79

Browse files
committed
fixup! refactor(config): replace IConfig with IAppConfig for improved type safety and clarity
Signed-off-by: Christian Hartmann <chris-hartmann@gmx.de>
1 parent 95f1379 commit d6a6f79

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

lib/Controller/ConfigController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,15 @@ public function updateAppConfig(string $configKey, mixed $configValue): DataResp
7272
} catch (\InvalidArgumentException $e) {
7373
return new DataResponse('Invalid value for ' . $configKey, Http::STATUS_BAD_REQUEST);
7474
}
75+
break;
7576

7677
case Constants::CONFIG_KEY_CREATIONALLOWEDGROUPS:
7778
try {
7879
$this->appConfig->setAppValueArray($configKey, $configValue);
7980
} catch (\InvalidArgumentException $e) {
8081
return new DataResponse('Invalid value for ' . $configKey, Http::STATUS_BAD_REQUEST);
8182
}
83+
break;
8284
}
8385

8486
return new DataResponse();

tests/Integration/IntegrationBase.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
*/
88
namespace OCA\Forms\Tests\Integration;
99

10+
use OCA\Forms\AppInfo\Application;
1011
use OCA\Forms\Constants;
11-
use OCP\AppFramework\Services\IAppConfig;
1212
use OCP\DB\QueryBuilder\IQueryBuilder;
13+
use OCP\IAppConfig;
1314
use OCP\IDBConnection;
1415
use OCP\IUserManager;
1516
use Test\TestCase;
@@ -33,9 +34,9 @@ class IntegrationBase extends TestCase {
3334
public function setUp(): void {
3435
parent::setUp();
3536

36-
$appConfig = \OCP\AppFramework\Services::get(IAppConfig::class);
37+
$appConfig = \OCP\Server::get(IAppConfig::class);
3738
foreach (Constants::CONFIG_KEYS as $key) {
38-
$appConfig->deleteAppValue($key);
39+
$appConfig->deleteAppValue(Application::APP_ID, $key);
3940
}
4041

4142
$userManager = \OCP\Server::get(IUserManager::class);

tests/Unit/Service/ConfigServiceTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,20 +182,20 @@ public static function dataCanCreateForms() {
182182
return [
183183
'notRestriced' => [
184184
'config' => [
185-
'restrictCreation' => 'false',
185+
'restrictCreation' => false,
186186
],
187187
'expected' => true
188188
],
189189
'restrictedGroupAllowed' => [
190190
'config' => [
191-
'restrictCreation' => 'true',
191+
'restrictCreation' => true,
192192
'creationAllowedGroups' => '["usersGroup","notUsersGroup"]'
193193
],
194194
'expected' => true
195195
],
196196
'restrictedNotInGroup' => [
197197
'config' => [
198-
'restrictCreation' => 'true',
198+
'restrictCreation' => true,
199199
'creationAllowedGroups' => '["notUsersGroup"]'
200200
],
201201
'expected' => false

0 commit comments

Comments
 (0)