@@ -90,6 +90,7 @@ public static function dataGetCapabilities(): array {
9090 'inverted ' => true ,
9191 'cacheBuster ' => 'v1 ' ,
9292 'enabledThemes ' => ['default ' ],
93+ 'toastTimeout ' => 7000 ,
9394 ]],
9495 ['name1 ' , 'url2 ' , 'slogan3 ' , '#01e4a0 ' , '#ffffff ' , 'logo5 ' , 'background6 ' , '#fff ' , '#000 ' , 'http://localhost/ ' , false , '' , '' , '#0082c9 ' , [
9596 'name ' => 'name1 ' ,
@@ -117,6 +118,7 @@ public static function dataGetCapabilities(): array {
117118 'inverted ' => false ,
118119 'cacheBuster ' => 'v1 ' ,
119120 'enabledThemes ' => ['default ' ],
121+ 'toastTimeout ' => 7000 ,
120122 ]],
121123 ['name1 ' , 'url2 ' , 'slogan3 ' , '#000000 ' , '#ffffff ' , 'logo5 ' , 'backgroundColor ' , '#000000 ' , '#ffffff ' , 'http://localhost/ ' , true , '' , '' , '#0082c9 ' , [
122124 'name ' => 'name1 ' ,
@@ -144,6 +146,7 @@ public static function dataGetCapabilities(): array {
144146 'inverted ' => false ,
145147 'cacheBuster ' => 'v1 ' ,
146148 'enabledThemes ' => ['default ' ],
149+ 'toastTimeout ' => 7000 ,
147150 ]],
148151 ['name1 ' , 'url2 ' , 'slogan3 ' , '#000000 ' , '#ffffff ' , 'logo5 ' , 'backgroundColor ' , '#000000 ' , '#ffffff ' , 'http://localhost/ ' , false , '' , '' , '#0082c9 ' , [
149152 'name ' => 'name1 ' ,
@@ -171,6 +174,7 @@ public static function dataGetCapabilities(): array {
171174 'inverted ' => false ,
172175 'cacheBuster ' => 'v1 ' ,
173176 'enabledThemes ' => ['default ' ],
177+ 'toastTimeout ' => 7000 ,
174178 ]],
175179 ];
176180 }
@@ -339,5 +343,52 @@ public function testGetCapabilitiesWithUser(string $backgroundImage, bool $expec
339343 // New fields are always present
340344 $ this ->assertSame ('v1 ' , $ theming ['cacheBuster ' ]);
341345 $ this ->assertSame (['default ' ], $ theming ['enabledThemes ' ]);
346+ $ this ->assertSame (7000 , $ theming ['toastTimeout ' ]);
347+ }
348+
349+ public static function dataGetCapabilitiesToastTimeout (): array {
350+ return [
351+ 'default ' => [7000 , 7000 ],
352+ '15 seconds ' => [15000 , 15000 ],
353+ '30 seconds ' => [30000 , 30000 ],
354+ 'never dismiss ' => [-1 , -1 ],
355+ 'invalid falls back to default ' => [1234 , 7000 ],
356+ ];
357+ }
358+
359+ #[\PHPUnit \Framework \Attributes \DataProvider(methodName: 'dataGetCapabilitiesToastTimeout ' )]
360+ public function testGetCapabilitiesToastTimeout (int $ storedTimeout , int $ expectedTimeout ): void {
361+ $ user = $ this ->createMock (IUser::class);
362+ $ user ->method ('getUID ' )->willReturn ('user1 ' );
363+ $ this ->userSession ->method ('getUser ' )->willReturn ($ user );
364+
365+ $ this ->theming ->method ('getDefaultColorPrimary ' )->willReturn ('#0082c9 ' );
366+ $ this ->theming ->method ('getColorPrimary ' )->willReturn ('#0082c9 ' );
367+ $ this ->theming ->method ('getTextColorPrimary ' )->willReturn ('#ffffff ' );
368+ $ this ->theming ->method ('getName ' )->willReturn ('Name ' );
369+ $ this ->theming ->method ('getProductName ' )->willReturn ('Name ' );
370+ $ this ->theming ->method ('getBaseUrl ' )->willReturn ('http://example.com/ ' );
371+ $ this ->theming ->method ('getImprintUrl ' )->willReturn ('' );
372+ $ this ->theming ->method ('getPrivacyUrl ' )->willReturn ('' );
373+ $ this ->theming ->method ('getSlogan ' )->willReturn ('Slogan ' );
374+ $ this ->theming ->method ('getColorBackground ' )->willReturn (BackgroundService::DEFAULT_COLOR );
375+ $ this ->theming ->method ('getTextColorBackground ' )->willReturn ('#ffffff ' );
376+ $ this ->theming ->method ('getDefaultColorBackground ' )->willReturn ('#0082c9 ' );
377+ $ this ->theming ->method ('getLogo ' )->willReturn ('/logo ' );
378+ $ this ->theming ->method ('getBackground ' )->willReturn ('/background ' );
379+
380+ $ this ->appConfig ->method ('getValueString ' )->willReturn ('' );
381+ $ this ->userConfig ->method ('getValueString ' )->willReturn (BackgroundService::BACKGROUND_DEFAULT );
382+ $ this ->userConfig ->method ('getValueInt ' )->willReturn ($ storedTimeout );
383+
384+ $ this ->util ->method ('invertTextColor ' )->willReturn (false );
385+ $ this ->util ->method ('elementColor ' )->willReturn ('#0082c9 ' );
386+ $ this ->util ->method ('isBackgroundThemed ' )->willReturn (false );
387+ $ this ->util ->method ('getCacheBuster ' )->willReturn ('v1 ' );
388+ $ this ->themesService ->method ('getEnabledThemes ' )->willReturn (['default ' ]);
389+ $ this ->url ->method ('getAbsoluteURL ' )->willReturnCallback (fn (string $ url ) => 'http://localhost ' . $ url );
390+
391+ $ result = $ this ->capabilities ->getCapabilities ();
392+ $ this ->assertSame ($ expectedTimeout , $ result ['theming ' ]['toastTimeout ' ]);
342393 }
343394}
0 commit comments