@@ -164,6 +164,11 @@ public function testViewApps(): void {
164164 ->method ('getSystemValueBool ' )
165165 ->with ('appstoreenabled ' , true )
166166 ->willReturn (true );
167+ $ this ->config
168+ ->expects ($ this ->once ())
169+ ->method ('getAppValue ' )
170+ ->with ('settings ' , 'display_documentation_link ' , 'true ' )
171+ ->willReturn ('true ' );
167172 $ this ->navigationManager
168173 ->expects ($ this ->once ())
169174 ->method ('setActiveEntry ' )
@@ -209,6 +214,11 @@ public function testViewAppsAppstoreNotEnabled(): void {
209214 ->method ('getSystemValueBool ' )
210215 ->with ('appstoreenabled ' , true )
211216 ->willReturn (false );
217+ $ this ->config
218+ ->expects ($ this ->once ())
219+ ->method ('getAppValue ' )
220+ ->with ('settings ' , 'display_documentation_link ' , 'true ' )
221+ ->willReturn ('true ' );
212222 $ this ->navigationManager
213223 ->expects ($ this ->once ())
214224 ->method ('setActiveEntry ' )
@@ -243,4 +253,88 @@ public function testViewAppsAppstoreNotEnabled(): void {
243253
244254 $ this ->assertEquals ($ expected , $ this ->appSettingsController ->viewApps ());
245255 }
256+
257+ public function testDeveloperDocumentationLinkHiddenWhenConfigured (): void {
258+ $ this ->installer ->expects ($ this ->any ())
259+ ->method ('isUpdateAvailable ' )
260+ ->willReturn (false );
261+ $ this ->bundleFetcher ->expects ($ this ->once ())->method ('getBundles ' )->willReturn ([]);
262+ $ this ->config
263+ ->expects ($ this ->once ())
264+ ->method ('getSystemValueBool ' )
265+ ->with ('appstoreenabled ' , true )
266+ ->willReturn (true );
267+ $ this ->config
268+ ->expects ($ this ->once ())
269+ ->method ('getAppValue ' )
270+ ->with ('settings ' , 'display_documentation_link ' , 'true ' )
271+ ->willReturn ('false ' );
272+ $ this ->navigationManager
273+ ->expects ($ this ->once ())
274+ ->method ('setActiveEntry ' )
275+ ->with ('core_apps ' );
276+
277+ // When display_documentation_link is false, linkToDocs should not be called
278+ $ this ->urlGenerator
279+ ->expects ($ this ->never ())
280+ ->method ('linkToDocs ' );
281+
282+ $ providedStates = [];
283+ $ this ->initialState
284+ ->expects ($ this ->exactly (4 ))
285+ ->method ('provideInitialState ' )
286+ ->willReturnCallback (function ($ key , $ value ) use (&$ providedStates ) {
287+ $ providedStates [$ key ] = $ value ;
288+ });
289+
290+ $ this ->appSettingsController ->viewApps ();
291+
292+ // Assert that the developer docs state was provided with an empty string
293+ $ this ->assertArrayHasKey ('appstoreDeveloperDocs ' , $ providedStates );
294+ $ this ->assertEquals ('' , $ providedStates ['appstoreDeveloperDocs ' ]);
295+ }
296+
297+ public function testDeveloperDocumentationLinkShownByDefault (): void {
298+ $ this ->installer ->expects ($ this ->any ())
299+ ->method ('isUpdateAvailable ' )
300+ ->willReturn (false );
301+ $ this ->bundleFetcher ->expects ($ this ->once ())->method ('getBundles ' )->willReturn ([]);
302+ $ this ->config
303+ ->expects ($ this ->once ())
304+ ->method ('getSystemValueBool ' )
305+ ->with ('appstoreenabled ' , true )
306+ ->willReturn (true );
307+ $ this ->config
308+ ->expects ($ this ->once ())
309+ ->method ('getAppValue ' )
310+ ->with ('settings ' , 'display_documentation_link ' , 'true ' )
311+ ->willReturn ('true ' );
312+ $ this ->navigationManager
313+ ->expects ($ this ->once ())
314+ ->method ('setActiveEntry ' )
315+ ->with ('core_apps ' );
316+
317+ $ developerDocsUrl = 'https://docs.nextcloud.com/server/latest/developer_manual/ ' ;
318+
319+ // When display_documentation_link is true (default), linkToDocs should be called
320+ $ this ->urlGenerator
321+ ->expects ($ this ->once ())
322+ ->method ('linkToDocs ' )
323+ ->with ('developer-manual ' )
324+ ->willReturn ($ developerDocsUrl );
325+
326+ $ providedStates = [];
327+ $ this ->initialState
328+ ->expects ($ this ->exactly (4 ))
329+ ->method ('provideInitialState ' )
330+ ->willReturnCallback (function ($ key , $ value ) use (&$ providedStates ) {
331+ $ providedStates [$ key ] = $ value ;
332+ });
333+
334+ $ this ->appSettingsController ->viewApps ();
335+
336+ // Assert that the developer docs state was provided with the correct URL
337+ $ this ->assertArrayHasKey ('appstoreDeveloperDocs ' , $ providedStates );
338+ $ this ->assertEquals ($ developerDocsUrl , $ providedStates ['appstoreDeveloperDocs ' ]);
339+ }
246340}
0 commit comments