1111
1212use OCA \Forms \Service \ConfigService ;
1313use OCP \AppFramework \Http \DataResponse ;
14- use OCP \IConfig ;
14+ use OCP \AppFramework \ Services \ IAppConfig ;
1515use OCP \IRequest ;
1616
1717use PHPUnit \Framework \MockObject \MockObject ;
@@ -23,15 +23,15 @@ class ConfigControllerTest extends TestCase {
2323
2424 private ConfigController $ configController ;
2525 private ConfigService |MockObject $ configService ;
26- private IConfig |MockObject $ config ;
26+ private IAppConfig |MockObject $ config ;
2727 private LoggerInterface |MockObject $ logger ;
2828 private IRequest |MockObject $ request ;
2929
3030 public function setUp (): void {
3131 parent ::setUp ();
3232
3333 $ this ->configService = $ this ->createMock (ConfigService::class);
34- $ this ->config = $ this ->createMock (IConfig ::class);
34+ $ this ->config = $ this ->createMock (IAppConfig ::class);
3535 $ this ->logger = $ this ->createMock (LoggerInterface::class);
3636 $ this ->request = $ this ->createMock (IRequest::class);
3737
@@ -60,18 +60,18 @@ public function testGetAppConfig() {
6060
6161 public static function dataUpdateAppConfig () {
6262 return [
63- 'booleanConfig ' => [
63+ 'booleanAllowPermitAll ' => [
6464 'configKey ' => 'allowPermitAll ' ,
6565 'configValue ' => true ,
6666 'strConfig ' => 'true '
6767 ],
68- 'booleanConfig ' => [
68+ 'booleanAllowShowToAll ' => [
6969 'configKey ' => 'allowShowToAll ' ,
7070 'configValue ' => true ,
7171 'strConfig ' => 'true '
7272 ],
73- 'arrayConfig ' => [
74- 'configKey ' => 'allowPermitAll ' ,
73+ 'arrayCreationAllowedGroups ' => [
74+ 'configKey ' => 'creationAllowedGroups ' ,
7575 'configValue ' => [
7676 'admin ' ,
7777 'group1 '
@@ -91,9 +91,15 @@ public function testUpdateAppConfig(string $configKey, $configValue, string $str
9191 $ this ->logger ->expects ($ this ->once ())
9292 ->method ('debug ' );
9393
94- $ this ->config ->expects ($ this ->once ())
95- ->method ('setAppValue ' )
96- ->with ('forms ' , $ configKey , $ strConfig );
94+ if (is_array ($ configValue )) {
95+ $ this ->config ->expects ($ this ->once ())
96+ ->method ('setAppValueArray ' )
97+ ->with ($ configKey , $ configValue );
98+ } else {
99+ $ this ->config ->expects ($ this ->once ())
100+ ->method ('setAppValueBool ' )
101+ ->with ($ configKey , $ configValue );
102+ }
97103
98104 $ this ->assertEquals (new DataResponse (), $ this ->configController ->updateAppConfig ($ configKey , $ configValue ));
99105 }
@@ -103,7 +109,9 @@ public function testUpdateAppConfig_unknownKey() {
103109 ->method ('debug ' );
104110
105111 $ this ->config ->expects ($ this ->never ())
106- ->method ('setAppValue ' );
112+ ->method ('setAppValueBool ' );
113+ $ this ->config ->expects ($ this ->never ())
114+ ->method ('setAppValueArray ' );
107115
108116 $ this ->assertEquals (new DataResponse ('Unknown appConfig key: someUnknownKey ' , 400 ), $ this ->configController ->updateAppConfig ('someUnknownKey ' , 'storeThisValue! ' ));
109117 }
0 commit comments