@@ -56,11 +56,30 @@ private function getFilesSharingPart(array $data) {
5656 * @param (string[])[] $map Map of arguments to return types for the getAppValue function in the mock
5757 * @return string[]
5858 */
59- private function getResults (array $ map , bool $ federationEnabled = true ) {
59+ private function getResults (array $ map , array $ typedMap = [], bool $ federationEnabled = true ) {
6060 $ config = $ this ->getMockBuilder (IConfig::class)->disableOriginalConstructor ()->getMock ();
6161 $ appManager = $ this ->getMockBuilder (IAppManager::class)->disableOriginalConstructor ()->getMock ();
6262 $ config ->method ('getAppValue ' )->willReturnMap ($ map );
6363 $ appManager ->method ('isEnabledForAnyone ' )->with ('federation ' )->willReturn ($ federationEnabled );
64+
65+ if (empty ($ typedMap )) {
66+ $ appConfig = $ this ->createMock (IAppConfig::class);
67+ } else {
68+ // hack to help transition from old IConfig to new IAppConfig
69+ $ appConfig = $ this ->getMockBuilder (IAppConfig::class)->disableOriginalConstructor ()->getMock ();
70+ $ appConfig ->expects ($ this ->any ())->method ('getValueBool ' )->willReturnCallback (function (...$ args ) use ($ typedMap ): bool {
71+ foreach ($ typedMap as $ entry ) {
72+ if ($ entry [0 ] !== $ args [0 ] || $ entry [1 ] !== $ args [1 ]) {
73+ continue ;
74+ }
75+
76+ return $ entry [2 ];
77+ }
78+
79+ return false ;
80+ });
81+ }
82+
6483 $ shareManager = new Manager (
6584 $ this ->createMock (LoggerInterface::class),
6685 $ config ,
@@ -80,9 +99,10 @@ private function getResults(array $map, bool $federationEnabled = true) {
8099 $ this ->createMock (KnownUserService::class),
81100 $ this ->createMock (ShareDisableChecker::class),
82101 $ this ->createMock (IDateTimeZone::class),
83- $ this -> createMock (IAppConfig::class) ,
102+ $ appConfig ,
84103 );
85- $ cap = new Capabilities ($ config , $ shareManager , $ appManager );
104+
105+ $ cap = new Capabilities ($ config , $ appConfig , $ shareManager , $ appManager );
86106 $ result = $ this ->getFilesSharingPart ($ cap ->getCapabilities ());
87107 return $ result ;
88108 }
@@ -135,9 +155,11 @@ public function testLinkPassword(): void {
135155 ['core ' , 'shareapi_enabled ' , 'yes ' , 'yes ' ],
136156 ['core ' , 'shareapi_allow_links ' , 'yes ' , 'yes ' ],
137157 ['core ' , 'shareapi_enforce_links_password_excluded_groups ' , '' , '' ],
138- ['core ' , 'shareapi_enforce_links_password ' , 'no ' , 'yes ' ],
139158 ];
140- $ result = $ this ->getResults ($ map );
159+ $ typedMap = [
160+ ['core ' , 'shareapi_enforce_links_password ' , true ],
161+ ];
162+ $ result = $ this ->getResults ($ map , $ typedMap );
141163 $ this ->assertArrayHasKey ('password ' , $ result ['public ' ]);
142164 $ this ->assertArrayHasKey ('enforced ' , $ result ['public ' ]['password ' ]);
143165 $ this ->assertTrue ($ result ['public ' ]['password ' ]['enforced ' ]);
@@ -328,7 +350,7 @@ public function testFederatedSharingExpirationDate(): void {
328350 }
329351
330352 public function testFederatedSharingDisabled (): void {
331- $ result = $ this ->getResults ([], false );
353+ $ result = $ this ->getResults ([], federationEnabled: false );
332354 $ this ->assertArrayHasKey ('federation ' , $ result );
333355 $ this ->assertFalse ($ result ['federation ' ]['incoming ' ]);
334356 $ this ->assertFalse ($ result ['federation ' ]['outgoing ' ]);
0 commit comments