Skip to content

Commit 7708bf4

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 7708bf4

3 files changed

Lines changed: 11 additions & 10 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: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
*/
88
namespace OCA\Forms\Tests\Integration;
99

10-
use OCA\Forms\Constants;
11-
use OCP\AppFramework\Services\IAppConfig;
10+
use OCA\Forms\AppInfo\Application;
1211
use OCP\DB\QueryBuilder\IQueryBuilder;
12+
use OCP\IAppConfig;
1313
use OCP\IDBConnection;
1414
use OCP\IUserManager;
1515
use Test\TestCase;
@@ -18,7 +18,8 @@
1818
* @group DB
1919
*/
2020
class IntegrationBase extends TestCase {
21-
protected array $testForms;
21+
/** @var Array */
22+
protected $testForms;
2223

2324
/**
2425
* Users that are needed by this test case
@@ -33,10 +34,8 @@ class IntegrationBase extends TestCase {
3334
public function setUp(): void {
3435
parent::setUp();
3536

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

4140
$userManager = \OCP\Server::get(IUserManager::class);
4241
foreach ($this->users as $userId => $displayName) {

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)