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 ;
@@ -27,7 +27,7 @@ class ConfigControllerTest extends TestCase {
2727 /** @var ConfigService */
2828 private $ configService ;
2929
30- /** @var IConfig |MockObject */
30+ /** @var IAppConfig |MockObject */
3131 private $ config ;
3232
3333 /** @var LoggerInterface|MockObject */
@@ -40,7 +40,7 @@ public function setUp(): void {
4040 parent ::setUp ();
4141
4242 $ this ->configService = $ this ->createMock (ConfigService::class);
43- $ this ->config = $ this ->createMock (IConfig ::class);
43+ $ this ->config = $ this ->createMock (IAppConfig ::class);
4444 $ this ->logger = $ this ->createMock (LoggerInterface::class);
4545 $ this ->request = $ this ->createMock (IRequest::class);
4646
@@ -69,18 +69,18 @@ public function testGetAppConfig() {
6969
7070 public static function dataUpdateAppConfig () {
7171 return [
72- 'booleanConfig ' => [
72+ 'booleanAllowPermitAll ' => [
7373 'configKey ' => 'allowPermitAll ' ,
7474 'configValue ' => true ,
7575 'strConfig ' => 'true '
7676 ],
77- 'booleanConfig ' => [
77+ 'booleanAllowShowToAll ' => [
7878 'configKey ' => 'allowShowToAll ' ,
7979 'configValue ' => true ,
8080 'strConfig ' => 'true '
8181 ],
82- 'arrayConfig ' => [
83- 'configKey ' => 'allowPermitAll ' ,
82+ 'arrayCreationAllowedGroups ' => [
83+ 'configKey ' => 'creationAllowedGroups ' ,
8484 'configValue ' => [
8585 'admin ' ,
8686 'group1 '
@@ -100,9 +100,15 @@ public function testUpdateAppConfig(string $configKey, $configValue, string $str
100100 $ this ->logger ->expects ($ this ->once ())
101101 ->method ('debug ' );
102102
103- $ this ->config ->expects ($ this ->once ())
104- ->method ('setAppValue ' )
105- ->with ('forms ' , $ configKey , $ strConfig );
103+ if (is_array ($ configValue )) {
104+ $ this ->config ->expects ($ this ->once ())
105+ ->method ('setAppValueArray ' )
106+ ->with ($ configKey , $ configValue );
107+ } else {
108+ $ this ->config ->expects ($ this ->once ())
109+ ->method ('setAppValueBool ' )
110+ ->with ($ configKey , $ configValue );
111+ }
106112
107113 $ this ->assertEquals (new DataResponse (), $ this ->configController ->updateAppConfig ($ configKey , $ configValue ));
108114 }
@@ -112,7 +118,9 @@ public function testUpdateAppConfig_unknownKey() {
112118 ->method ('debug ' );
113119
114120 $ this ->config ->expects ($ this ->never ())
115- ->method ('setAppValue ' );
121+ ->method ('setAppValueBool ' );
122+ $ this ->config ->expects ($ this ->never ())
123+ ->method ('setAppValueArray ' );
116124
117125 $ this ->assertEquals (new DataResponse ('Unknown appConfig key: someUnknownKey ' , 400 ), $ this ->configController ->updateAppConfig ('someUnknownKey ' , 'storeThisValue! ' ));
118126 }
0 commit comments