2121use OCA \Libresign \Tests \Unit \TestCase ;
2222use OCP \AppFramework \Utility \ITimeFactory ;
2323use OCP \EventDispatcher \IEventDispatcher ;
24- use OCP \Exceptions \AppConfigTypeConflictException ;
2524use OCP \Files \IRootFolder ;
2625use OCP \IAppConfig ;
2726use OCP \IL10N ;
@@ -156,7 +155,7 @@ public function testPropagateIdentifiedDateSkipsCurrentRequestAndUpdatesSiblings
156155 $ this ->service ->save ($ identifyMethod );
157156 }
158157
159- public function testGetSavedSettingsFallsBackToDefaultWhenStoredValueIsInvalid (): void {
158+ public function testGetSavedSettingsThrowsWhenStoredValueIsInvalid (): void {
160159 $ this ->appConfig
161160 ->expects ($ this ->once ())
162161 ->method ('clearCache ' )
@@ -168,78 +167,12 @@ public function testGetSavedSettingsFallsBackToDefaultWhenStoredValueIsInvalid()
168167 ->with (Application::APP_ID , 'identify_methods ' , [])
169168 ->willThrowException (new \TypeError ('Invalid app config value type ' ));
170169
171- $ this ->logger
172- ->expects ($ this ->once ())
173- ->method ('warning ' )
174- ->with (
175- 'Invalid identify_methods app config; falling back to defaults. ' ,
176- $ this ->callback (static function (array $ context ): bool {
177- return isset ($ context ['exception ' ]) && $ context ['exception ' ] instanceof \TypeError;
178- })
179- );
180-
181- $ this ->assertSame ([], $ this ->service ->getSavedSettings ());
182- }
183-
184- public function testGetSavedSettingsDecodesLegacyJsonStringWhenStoredValueTypeConflicts (): void {
185- $ this ->appConfig
186- ->expects ($ this ->once ())
187- ->method ('clearCache ' )
188- ->with (true );
189-
190- $ this ->appConfig
191- ->expects ($ this ->once ())
192- ->method ('getValueArray ' )
193- ->with (Application::APP_ID , 'identify_methods ' , [])
194- ->willThrowException (new AppConfigTypeConflictException ('conflict with value type from database ' ));
195-
196- $ this ->appConfig
197- ->expects ($ this ->once ())
198- ->method ('getValueString ' )
199- ->with (Application::APP_ID , 'identify_methods ' , '' )
200- ->willReturn ('[{"name":"account","enabled":true}] ' );
201-
202170 $ this ->logger
203171 ->expects ($ this ->never ())
204172 ->method ('warning ' );
205173
206- $ this ->assertSame ([
207- [
208- 'name ' => 'account ' ,
209- 'enabled ' => true ,
210- ],
211- ], $ this ->service ->getSavedSettings ());
212- }
213-
214- public function testGetSavedSettingsFallsBackToDefaultWhenLegacyStringIsInvalid (): void {
215- $ this ->appConfig
216- ->expects ($ this ->once ())
217- ->method ('clearCache ' )
218- ->with (true );
219-
220- $ this ->appConfig
221- ->expects ($ this ->once ())
222- ->method ('getValueArray ' )
223- ->with (Application::APP_ID , 'identify_methods ' , [])
224- ->willThrowException (new AppConfigTypeConflictException ('conflict with value type from database ' ));
225-
226- $ this ->appConfig
227- ->expects ($ this ->once ())
228- ->method ('getValueString ' )
229- ->with (Application::APP_ID , 'identify_methods ' , '' )
230- ->willReturn ('invalid ' );
231-
232- $ this ->logger
233- ->expects ($ this ->once ())
234- ->method ('warning ' )
235- ->with (
236- 'Invalid identify_methods app config; falling back to defaults. ' ,
237- $ this ->callback (static function (array $ context ): bool {
238- return isset ($ context ['exception ' ]) && $ context ['exception ' ] instanceof AppConfigTypeConflictException;
239- })
240- );
241-
242- $ this ->assertSame ([], $ this ->service ->getSavedSettings ());
174+ $ this ->expectException (\TypeError::class);
175+ $ this ->service ->getSavedSettings ();
243176 }
244177
245178 public function testGetSavedSettingsReloadsAppConfigBeforeReading (): void {
0 commit comments