2020use OCP \AppFramework \Services \IInitialState ;
2121use OCP \Files \AppData \IAppDataFactory ;
2222use OCP \Http \Client \IClientService ;
23- use OCP \IAppConfig ;
2423use OCP \IConfig ;
2524use OCP \IL10N ;
2625use OCP \INavigationManager ;
@@ -41,7 +40,6 @@ class AppSettingsControllerTest extends TestCase {
4140 private IRequest &MockObject $ request ;
4241 private IL10N &MockObject $ l10n ;
4342 private IConfig &MockObject $ config ;
44- private IAppConfig &MockObject $ appConfig ;
4543 private INavigationManager &MockObject $ navigationManager ;
4644 private AppManager &MockObject $ appManager ;
4745 private CategoryFetcher &MockObject $ categoryFetcher ;
@@ -67,7 +65,6 @@ protected function setUp(): void {
6765 ->method ('t ' )
6866 ->willReturnArgument (0 );
6967 $ this ->config = $ this ->createMock (IConfig::class);
70- $ this ->appConfig = $ this ->createMock (IAppConfig::class);
7168 $ this ->navigationManager = $ this ->createMock (INavigationManager::class);
7269 $ this ->appManager = $ this ->createMock (AppManager::class);
7370 $ this ->categoryFetcher = $ this ->createMock (CategoryFetcher::class);
@@ -99,7 +96,6 @@ protected function setUp(): void {
9996 $ this ->initialState ,
10097 $ this ->discoverFetcher ,
10198 $ this ->clientService ,
102- $ this ->appConfig ,
10399 );
104100 }
105101
@@ -168,31 +164,14 @@ public function testViewApps(): void {
168164 ->method ('getSystemValueBool ' )
169165 ->with ('appstoreenabled ' , true )
170166 ->willReturn (true );
171- $ this ->appConfig
172- ->expects ($ this ->once ())
173- ->method ('getValueBool ' )
174- ->with ('settings ' , 'display_documentation_link ' , true )
175- ->willReturn (true );
176167 $ this ->navigationManager
177168 ->expects ($ this ->once ())
178169 ->method ('setActiveEntry ' )
179170 ->with ('core_apps ' );
180171
181- // Test that developer docs link is generated correctly
182- $ this ->urlGenerator
183- ->expects ($ this ->once ())
184- ->method ('linkToDocs ' )
185- ->with ('developer-manual ' )
186- ->willReturn ('https://docs.nextcloud.com/server/latest/developer_manual/ ' );
187-
188172 $ this ->initialState
189173 ->expects ($ this ->exactly (4 ))
190- ->method ('provideInitialState ' )
191- ->willReturnCallback (function ($ key , $ value ) {
192- if ($ key === 'appstoreDeveloperDocs ' ) {
193- $ this ->assertEquals ('https://docs.nextcloud.com/server/latest/developer_manual/ ' , $ value );
194- }
195- });
174+ ->method ('provideInitialState ' );
196175
197176 $ policy = new ContentSecurityPolicy ();
198177 $ policy ->addAllowedImageDomain ('https://usercontent.apps.nextcloud.com ' );
@@ -218,31 +197,14 @@ public function testViewAppsAppstoreNotEnabled(): void {
218197 ->method ('getSystemValueBool ' )
219198 ->with ('appstoreenabled ' , true )
220199 ->willReturn (false );
221- $ this ->appConfig
222- ->expects ($ this ->once ())
223- ->method ('getValueBool ' )
224- ->with ('settings ' , 'display_documentation_link ' , true )
225- ->willReturn (true );
226200 $ this ->navigationManager
227201 ->expects ($ this ->once ())
228202 ->method ('setActiveEntry ' )
229203 ->with ('core_apps ' );
230204
231- // Test that developer docs link is still generated even when appstore is disabled
232- $ this ->urlGenerator
233- ->expects ($ this ->once ())
234- ->method ('linkToDocs ' )
235- ->with ('developer-manual ' )
236- ->willReturn ('https://docs.nextcloud.com/server/latest/developer_manual/ ' );
237-
238205 $ this ->initialState
239206 ->expects ($ this ->exactly (4 ))
240- ->method ('provideInitialState ' )
241- ->willReturnCallback (function ($ key , $ value ) {
242- if ($ key === 'appstoreDeveloperDocs ' ) {
243- $ this ->assertEquals ('https://docs.nextcloud.com/server/latest/developer_manual/ ' , $ value );
244- }
245- });
207+ ->method ('provideInitialState ' );
246208
247209 $ policy = new ContentSecurityPolicy ();
248210 $ policy ->addAllowedImageDomain ('https://usercontent.apps.nextcloud.com ' );
@@ -257,88 +219,4 @@ public function testViewAppsAppstoreNotEnabled(): void {
257219
258220 $ this ->assertEquals ($ expected , $ this ->appSettingsController ->viewApps ());
259221 }
260-
261- public function testDeveloperDocumentationLinkHiddenWhenConfigured (): void {
262- $ this ->installer ->expects ($ this ->any ())
263- ->method ('isUpdateAvailable ' )
264- ->willReturn (false );
265- $ this ->bundleFetcher ->expects ($ this ->once ())->method ('getBundles ' )->willReturn ([]);
266- $ this ->config
267- ->expects ($ this ->once ())
268- ->method ('getSystemValueBool ' )
269- ->with ('appstoreenabled ' , true )
270- ->willReturn (true );
271- $ this ->appConfig
272- ->expects ($ this ->once ())
273- ->method ('getValueBool ' )
274- ->with ('settings ' , 'display_documentation_link ' , true )
275- ->willReturn (false );
276- $ this ->navigationManager
277- ->expects ($ this ->once ())
278- ->method ('setActiveEntry ' )
279- ->with ('core_apps ' );
280-
281- // When display_documentation_link is false, linkToDocs should not be called
282- $ this ->urlGenerator
283- ->expects ($ this ->never ())
284- ->method ('linkToDocs ' );
285-
286- $ providedStates = [];
287- $ this ->initialState
288- ->expects ($ this ->exactly (4 ))
289- ->method ('provideInitialState ' )
290- ->willReturnCallback (function ($ key , $ value ) use (&$ providedStates ) {
291- $ providedStates [$ key ] = $ value ;
292- });
293-
294- $ this ->appSettingsController ->viewApps ();
295-
296- // Assert that the developer docs state was provided with an empty string
297- $ this ->assertArrayHasKey ('appstoreDeveloperDocs ' , $ providedStates );
298- $ this ->assertEquals ('' , $ providedStates ['appstoreDeveloperDocs ' ]);
299- }
300-
301- public function testDeveloperDocumentationLinkShownByDefault (): void {
302- $ this ->installer ->expects ($ this ->any ())
303- ->method ('isUpdateAvailable ' )
304- ->willReturn (false );
305- $ this ->bundleFetcher ->expects ($ this ->once ())->method ('getBundles ' )->willReturn ([]);
306- $ this ->config
307- ->expects ($ this ->once ())
308- ->method ('getSystemValueBool ' )
309- ->with ('appstoreenabled ' , true )
310- ->willReturn (true );
311- $ this ->appConfig
312- ->expects ($ this ->once ())
313- ->method ('getValueBool ' )
314- ->with ('settings ' , 'display_documentation_link ' , true )
315- ->willReturn (true );
316- $ this ->navigationManager
317- ->expects ($ this ->once ())
318- ->method ('setActiveEntry ' )
319- ->with ('core_apps ' );
320-
321- $ developerDocsUrl = 'https://docs.nextcloud.com/server/latest/developer_manual/ ' ;
322-
323- // When display_documentation_link is true (default), linkToDocs should be called
324- $ this ->urlGenerator
325- ->expects ($ this ->once ())
326- ->method ('linkToDocs ' )
327- ->with ('developer-manual ' )
328- ->willReturn ($ developerDocsUrl );
329-
330- $ providedStates = [];
331- $ this ->initialState
332- ->expects ($ this ->exactly (4 ))
333- ->method ('provideInitialState ' )
334- ->willReturnCallback (function ($ key , $ value ) use (&$ providedStates ) {
335- $ providedStates [$ key ] = $ value ;
336- });
337-
338- $ this ->appSettingsController ->viewApps ();
339-
340- // Assert that the developer docs state was provided with the correct URL
341- $ this ->assertArrayHasKey ('appstoreDeveloperDocs ' , $ providedStates );
342- $ this ->assertEquals ($ developerDocsUrl , $ providedStates ['appstoreDeveloperDocs ' ]);
343- }
344222}
0 commit comments