@@ -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 ' )
@@ -254,6 +264,11 @@ public function testDeveloperDocumentationLinkIsProvided(): void {
254264 ->method ('getSystemValueBool ' )
255265 ->with ('appstoreenabled ' , true )
256266 ->willReturn (true );
267+ $ this ->config
268+ ->expects ($ this ->once ())
269+ ->method ('getAppValue ' )
270+ ->with ('settings ' , 'display_documentation_link ' , 'true ' )
271+ ->willReturn ('true ' );
257272 $ this ->navigationManager
258273 ->expects ($ this ->once ())
259274 ->method ('setActiveEntry ' )
@@ -297,6 +312,11 @@ public function testDeveloperDocumentationLinkWithDifferentUrls(string $expected
297312 ->method ('getSystemValueBool ' )
298313 ->with ('appstoreenabled ' , true )
299314 ->willReturn (true );
315+ $ this ->config
316+ ->expects ($ this ->once ())
317+ ->method ('getAppValue ' )
318+ ->with ('settings ' , 'display_documentation_link ' , 'true ' )
319+ ->willReturn ('true ' );
300320 $ this ->navigationManager
301321 ->expects ($ this ->once ())
302322 ->method ('setActiveEntry ' )
@@ -332,4 +352,88 @@ public function developerDocsUrlProvider(): array {
332352 'with anchor ' => ['https://docs.nextcloud.com/server/latest/developer_manual/#getting-started ' ],
333353 ];
334354 }
355+
356+ public function testDeveloperDocumentationLinkHiddenWhenConfigured (): void {
357+ $ this ->installer ->expects ($ this ->any ())
358+ ->method ('isUpdateAvailable ' )
359+ ->willReturn (false );
360+ $ this ->bundleFetcher ->expects ($ this ->once ())->method ('getBundles ' )->willReturn ([]);
361+ $ this ->config
362+ ->expects ($ this ->once ())
363+ ->method ('getSystemValueBool ' )
364+ ->with ('appstoreenabled ' , true )
365+ ->willReturn (true );
366+ $ this ->config
367+ ->expects ($ this ->once ())
368+ ->method ('getAppValue ' )
369+ ->with ('settings ' , 'display_documentation_link ' , 'true ' )
370+ ->willReturn ('false ' );
371+ $ this ->navigationManager
372+ ->expects ($ this ->once ())
373+ ->method ('setActiveEntry ' )
374+ ->with ('core_apps ' );
375+
376+ // When display_documentation_link is false, linkToDocs should not be called
377+ $ this ->urlGenerator
378+ ->expects ($ this ->never ())
379+ ->method ('linkToDocs ' );
380+
381+ $ providedStates = [];
382+ $ this ->initialState
383+ ->expects ($ this ->exactly (4 ))
384+ ->method ('provideInitialState ' )
385+ ->willReturnCallback (function ($ key , $ value ) use (&$ providedStates ) {
386+ $ providedStates [$ key ] = $ value ;
387+ });
388+
389+ $ this ->appSettingsController ->viewApps ();
390+
391+ // Assert that the developer docs state was provided with an empty string
392+ $ this ->assertArrayHasKey ('appstoreDeveloperDocs ' , $ providedStates );
393+ $ this ->assertEquals ('' , $ providedStates ['appstoreDeveloperDocs ' ]);
394+ }
395+
396+ public function testDeveloperDocumentationLinkShownByDefault (): void {
397+ $ this ->installer ->expects ($ this ->any ())
398+ ->method ('isUpdateAvailable ' )
399+ ->willReturn (false );
400+ $ this ->bundleFetcher ->expects ($ this ->once ())->method ('getBundles ' )->willReturn ([]);
401+ $ this ->config
402+ ->expects ($ this ->once ())
403+ ->method ('getSystemValueBool ' )
404+ ->with ('appstoreenabled ' , true )
405+ ->willReturn (true );
406+ $ this ->config
407+ ->expects ($ this ->once ())
408+ ->method ('getAppValue ' )
409+ ->with ('settings ' , 'display_documentation_link ' , 'true ' )
410+ ->willReturn ('true ' );
411+ $ this ->navigationManager
412+ ->expects ($ this ->once ())
413+ ->method ('setActiveEntry ' )
414+ ->with ('core_apps ' );
415+
416+ $ developerDocsUrl = 'https://docs.nextcloud.com/server/latest/developer_manual/ ' ;
417+
418+ // When display_documentation_link is true (default), linkToDocs should be called
419+ $ this ->urlGenerator
420+ ->expects ($ this ->once ())
421+ ->method ('linkToDocs ' )
422+ ->with ('developer-manual ' )
423+ ->willReturn ($ developerDocsUrl );
424+
425+ $ providedStates = [];
426+ $ this ->initialState
427+ ->expects ($ this ->exactly (4 ))
428+ ->method ('provideInitialState ' )
429+ ->willReturnCallback (function ($ key , $ value ) use (&$ providedStates ) {
430+ $ providedStates [$ key ] = $ value ;
431+ });
432+
433+ $ this ->appSettingsController ->viewApps ();
434+
435+ // Assert that the developer docs state was provided with the correct URL
436+ $ this ->assertArrayHasKey ('appstoreDeveloperDocs ' , $ providedStates );
437+ $ this ->assertEquals ($ developerDocsUrl , $ providedStates ['appstoreDeveloperDocs ' ]);
438+ }
335439}
0 commit comments