2929use OCA \Provisioning_API \Controller \AppConfigController ;
3030use OCP \AppFramework \Http ;
3131use OCP \AppFramework \Http \DataResponse ;
32+ use OCP \Exceptions \AppConfigUnknownKeyException ;
3233use OCP \IAppConfig ;
3334use OCP \IGroupManager ;
3435use OCP \IL10N ;
@@ -212,6 +213,7 @@ public function dataSetValue() {
212213 ['app2 ' , 'key ' , '42 ' , null , null , Http::STATUS_OK , IAppConfig::VALUE_STRING ],
213214 ['app2 ' , 'key ' , 'secret ' , null , null , Http::STATUS_OK , IAppConfig::VALUE_STRING | IAppConfig::VALUE_SENSITIVE ],
214215 ['app2 ' , 'key ' , json_encode ([4 , 2 ]), null , null , Http::STATUS_OK , IAppConfig::VALUE_ARRAY ],
216+ ['app2 ' , 'key ' , json_encode ([4 , 2 ]), null , null , Http::STATUS_OK , new AppConfigUnknownKeyException ()],
215217 ];
216218 }
217219
@@ -222,9 +224,9 @@ public function dataSetValue() {
222224 * @param string|null $value
223225 * @param \Exception|null $appThrows
224226 * @param \Exception|null $keyThrows
225- * @param int $status
227+ * @param int|\Throwable $status
226228 */
227- public function testSetValue ($ app , $ key , $ value , $ appThrows , $ keyThrows , $ status , int $ type = IAppConfig::VALUE_MIXED ) {
229+ public function testSetValue ($ app , $ key , $ value , $ appThrows , $ keyThrows , $ status , int | \ Throwable $ type = IAppConfig::VALUE_MIXED ) {
228230 $ adminUser = $ this ->createMock (IUser::class);
229231 $ adminUser ->expects ($ this ->once ())
230232 ->method ('getUid ' )
@@ -267,18 +269,25 @@ public function testSetValue($app, $key, $value, $appThrows, $keyThrows, $status
267269 ->method ('verifyConfigKey ' )
268270 ->with ($ app , $ key );
269271
270- $ this ->appConfig ->expects ($ this ->once ())
271- ->method ('getDetails ' )
272- ->with ($ app , $ key )
273- ->willReturn ([
274- 'app ' => $ app ,
275- 'key ' => $ key ,
276- 'value ' => '' , // 🤷
277- 'type ' => $ type ,
278- 'lazy ' => false ,
279- 'typeString ' => (string )$ type , // this is not accurate, but acceptable
280- 'sensitive ' => ($ type & IAppConfig::VALUE_SENSITIVE ) !== 0 ,
281- ]);
272+ if ($ type instanceof \Throwable) {
273+ $ this ->appConfig ->expects ($ this ->once ())
274+ ->method ('getDetails ' )
275+ ->with ($ app , $ key )
276+ ->willThrowException ($ type );
277+ } else {
278+ $ this ->appConfig ->expects ($ this ->once ())
279+ ->method ('getDetails ' )
280+ ->with ($ app , $ key )
281+ ->willReturn ([
282+ 'app ' => $ app ,
283+ 'key ' => $ key ,
284+ 'value ' => '' , // 🤷
285+ 'type ' => $ type ,
286+ 'lazy ' => false ,
287+ 'typeString ' => (string )$ type , // this is not accurate, but acceptable
288+ 'sensitive ' => ($ type & IAppConfig::VALUE_SENSITIVE ) !== 0 ,
289+ ]);
290+ }
282291
283292 $ configValueSetter = match ($ type ) {
284293 IAppConfig::VALUE_BOOL => 'setValueBool ' ,
0 commit comments