20
20
class SharingTest extends TestCase {
21
21
/** @var Sharing */
22
22
private $ admin ;
23
- /** @var IConfig */
23
+ /** @var IConfig&MockObject */
24
24
private $ config ;
25
- /** @var IL10N| MockObject */
25
+ /** @var IL10N& MockObject */
26
26
private $ l10n ;
27
27
/** @var IManager|MockObject */
28
28
private $ shareManager ;
@@ -35,9 +35,7 @@ class SharingTest extends TestCase {
35
35
36
36
protected function setUp (): void {
37
37
parent ::setUp ();
38
- /** @var IConfig|MockObject */
39
38
$ this ->config = $ this ->getMockBuilder (IConfig::class)->getMock ();
40
- /** @var IL10N|MockObject */
41
39
$ this ->l10n = $ this ->getMockBuilder (IL10N ::class)->getMock ();
42
40
43
41
/** @var IManager|MockObject */
@@ -82,7 +80,7 @@ public function testGetFormWithoutExcludedGroups(): void {
82
80
['core ' , 'shareapi_expire_after_n_days ' , '7 ' , '7 ' ],
83
81
['core ' , 'shareapi_enforce_expire_date ' , 'no ' , 'no ' ],
84
82
['core ' , 'shareapi_exclude_groups ' , 'no ' , 'no ' ],
85
- ['core ' , 'shareapi_public_link_disclaimertext ' , null , 'Lorem ipsum ' ],
83
+ ['core ' , 'shareapi_public_link_disclaimertext ' , '' , 'Lorem ipsum ' ],
86
84
['core ' , 'shareapi_enable_link_password_by_default ' , 'no ' , 'yes ' ],
87
85
['core ' , 'shareapi_default_permissions ' , (string )Constants::PERMISSION_ALL , Constants::PERMISSION_ALL ],
88
86
['core ' , 'shareapi_default_internal_expire_date ' , 'no ' , 'no ' ],
@@ -98,50 +96,53 @@ public function testGetFormWithoutExcludedGroups(): void {
98
96
->willReturn (false );
99
97
100
98
$ this ->appManager ->method ('isEnabledForUser ' )->with ('files_sharing ' )->willReturn (false );
99
+
100
+ $ initialStateCalls = [];
101
101
$ this ->initialState
102
102
->expects ($ this ->exactly (3 ))
103
103
->method ('provideInitialState ' )
104
- ->withConsecutive (
105
- ['sharingAppEnabled ' , false ],
106
- ['sharingDocumentation ' , '' ],
107
- [
108
- 'sharingSettings ' ,
109
- [
110
- 'allowGroupSharing ' => true ,
111
- 'allowLinks ' => true ,
112
- 'allowPublicUpload ' => true ,
113
- 'allowResharing ' => true ,
114
- 'allowShareDialogUserEnumeration ' => true ,
115
- 'restrictUserEnumerationToGroup ' => false ,
116
- 'restrictUserEnumerationToPhone ' => false ,
117
- 'restrictUserEnumerationFullMatch ' => true ,
118
- 'restrictUserEnumerationFullMatchUserId ' => true ,
119
- 'restrictUserEnumerationFullMatchEmail ' => true ,
120
- 'restrictUserEnumerationFullMatchIgnoreSecondDN ' => false ,
121
- 'enforceLinksPassword ' => false ,
122
- 'onlyShareWithGroupMembers ' => false ,
123
- 'enabled ' => true ,
124
- 'defaultExpireDate ' => false ,
125
- 'expireAfterNDays ' => '7 ' ,
126
- 'enforceExpireDate ' => false ,
127
- 'excludeGroups ' => 'no ' ,
128
- 'excludeGroupsList ' => [],
129
- 'publicShareDisclaimerText ' => 'Lorem ipsum ' ,
130
- 'enableLinkPasswordByDefault ' => true ,
131
- 'defaultPermissions ' => Constants::PERMISSION_ALL ,
132
- 'defaultInternalExpireDate ' => false ,
133
- 'internalExpireAfterNDays ' => '7 ' ,
134
- 'enforceInternalExpireDate ' => false ,
135
- 'defaultRemoteExpireDate ' => false ,
136
- 'remoteExpireAfterNDays ' => '7 ' ,
137
- 'enforceRemoteExpireDate ' => false ,
138
- 'allowLinksExcludeGroups ' => [],
139
- 'onlyShareWithGroupMembersExcludeGroupList ' => [],
140
- 'enforceLinksPasswordExcludedGroups ' => [],
141
- 'enforceLinksPasswordExcludedGroupsEnabled ' => false ,
142
- ]
143
- ],
144
- );
104
+ ->willReturnCallback (function (string $ key ) use (&$ initialStateCalls ) {
105
+ $ initialStateCalls [$ key ] = func_get_args ();
106
+ });
107
+
108
+ $ expectedInitialStateCalls = [
109
+ 'sharingAppEnabled ' => false ,
110
+ 'sharingDocumentation ' => '' ,
111
+ 'sharingSettings ' => [
112
+ 'allowGroupSharing ' => true ,
113
+ 'allowLinks ' => true ,
114
+ 'allowPublicUpload ' => true ,
115
+ 'allowResharing ' => true ,
116
+ 'allowShareDialogUserEnumeration ' => true ,
117
+ 'restrictUserEnumerationToGroup ' => false ,
118
+ 'restrictUserEnumerationToPhone ' => false ,
119
+ 'restrictUserEnumerationFullMatch ' => true ,
120
+ 'restrictUserEnumerationFullMatchUserId ' => true ,
121
+ 'restrictUserEnumerationFullMatchEmail ' => true ,
122
+ 'restrictUserEnumerationFullMatchIgnoreSecondDN ' => false ,
123
+ 'enforceLinksPassword ' => false ,
124
+ 'onlyShareWithGroupMembers ' => false ,
125
+ 'enabled ' => true ,
126
+ 'defaultExpireDate ' => false ,
127
+ 'expireAfterNDays ' => '7 ' ,
128
+ 'enforceExpireDate ' => false ,
129
+ 'excludeGroups ' => 'no ' ,
130
+ 'excludeGroupsList ' => [],
131
+ 'publicShareDisclaimerText ' => 'Lorem ipsum ' ,
132
+ 'enableLinkPasswordByDefault ' => true ,
133
+ 'defaultPermissions ' => Constants::PERMISSION_ALL ,
134
+ 'defaultInternalExpireDate ' => false ,
135
+ 'internalExpireAfterNDays ' => '7 ' ,
136
+ 'enforceInternalExpireDate ' => false ,
137
+ 'defaultRemoteExpireDate ' => false ,
138
+ 'remoteExpireAfterNDays ' => '7 ' ,
139
+ 'enforceRemoteExpireDate ' => false ,
140
+ 'allowLinksExcludeGroups ' => [],
141
+ 'onlyShareWithGroupMembersExcludeGroupList ' => [],
142
+ 'enforceLinksPasswordExcludedGroups ' => [],
143
+ 'enforceLinksPasswordExcludedGroupsEnabled ' => false ,
144
+ ]
145
+ ];
145
146
146
147
$ expected = new TemplateResponse (
147
148
'settings ' ,
@@ -151,6 +152,7 @@ public function testGetFormWithoutExcludedGroups(): void {
151
152
);
152
153
153
154
$ this ->assertEquals ($ expected , $ this ->admin ->getForm ());
155
+ $ this ->assertEquals (sort ($ expectedInitialStateCalls ), sort ($ initialStateCalls ), 'Provided initial state does not match ' );
154
156
}
155
157
156
158
public function testGetFormWithExcludedGroups (): void {
@@ -175,7 +177,7 @@ public function testGetFormWithExcludedGroups(): void {
175
177
['core ' , 'shareapi_expire_after_n_days ' , '7 ' , '7 ' ],
176
178
['core ' , 'shareapi_enforce_expire_date ' , 'no ' , 'no ' ],
177
179
['core ' , 'shareapi_exclude_groups ' , 'no ' , 'yes ' ],
178
- ['core ' , 'shareapi_public_link_disclaimertext ' , null , 'Lorem ipsum ' ],
180
+ ['core ' , 'shareapi_public_link_disclaimertext ' , '' , 'Lorem ipsum ' ],
179
181
['core ' , 'shareapi_enable_link_password_by_default ' , 'no ' , 'yes ' ],
180
182
['core ' , 'shareapi_default_permissions ' , (string )Constants::PERMISSION_ALL , Constants::PERMISSION_ALL ],
181
183
['core ' , 'shareapi_default_internal_expire_date ' , 'no ' , 'no ' ],
@@ -191,50 +193,53 @@ public function testGetFormWithExcludedGroups(): void {
191
193
->willReturn (false );
192
194
193
195
$ this ->appManager ->method ('isEnabledForUser ' )->with ('files_sharing ' )->willReturn (true );
196
+
197
+ $ initialStateCalls = [];
194
198
$ this ->initialState
195
199
->expects ($ this ->exactly (3 ))
196
200
->method ('provideInitialState ' )
197
- ->withConsecutive (
198
- ['sharingAppEnabled ' , true ],
199
- ['sharingDocumentation ' , '' ],
200
- [
201
- 'sharingSettings ' ,
202
- [
203
- 'allowGroupSharing ' => true ,
204
- 'allowLinks ' => true ,
205
- 'allowPublicUpload ' => true ,
206
- 'allowResharing ' => true ,
207
- 'allowShareDialogUserEnumeration ' => true ,
208
- 'restrictUserEnumerationToGroup ' => false ,
209
- 'restrictUserEnumerationToPhone ' => false ,
210
- 'restrictUserEnumerationFullMatch ' => true ,
211
- 'restrictUserEnumerationFullMatchUserId ' => true ,
212
- 'restrictUserEnumerationFullMatchEmail ' => true ,
213
- 'restrictUserEnumerationFullMatchIgnoreSecondDN ' => false ,
214
- 'enforceLinksPassword ' => false ,
215
- 'onlyShareWithGroupMembers ' => false ,
216
- 'enabled ' => true ,
217
- 'defaultExpireDate ' => false ,
218
- 'expireAfterNDays ' => '7 ' ,
219
- 'enforceExpireDate ' => false ,
220
- 'excludeGroups ' => 'yes ' ,
221
- 'excludeGroupsList ' => ['NoSharers ' ,'OtherNoSharers ' ],
222
- 'publicShareDisclaimerText ' => 'Lorem ipsum ' ,
223
- 'enableLinkPasswordByDefault ' => true ,
224
- 'defaultPermissions ' => Constants::PERMISSION_ALL ,
225
- 'defaultInternalExpireDate ' => false ,
226
- 'internalExpireAfterNDays ' => '7 ' ,
227
- 'enforceInternalExpireDate ' => false ,
228
- 'defaultRemoteExpireDate ' => false ,
229
- 'remoteExpireAfterNDays ' => '7 ' ,
230
- 'enforceRemoteExpireDate ' => false ,
231
- 'allowLinksExcludeGroups ' => [],
232
- 'onlyShareWithGroupMembersExcludeGroupList ' => [],
233
- 'enforceLinksPasswordExcludedGroups ' => [],
234
- 'enforceLinksPasswordExcludedGroupsEnabled ' => false ,
235
- ]
236
- ],
237
- );
201
+ ->willReturnCallback (function (string $ key ) use (&$ initialStateCalls ) {
202
+ $ initialStateCalls [$ key ] = func_get_args ();
203
+ });
204
+
205
+ $ expectedInitialStateCalls = [
206
+ 'sharingAppEnabled ' => true ,
207
+ 'sharingDocumentation ' => '' ,
208
+ 'sharingSettings ' => [
209
+ 'allowGroupSharing ' => true ,
210
+ 'allowLinks ' => true ,
211
+ 'allowPublicUpload ' => true ,
212
+ 'allowResharing ' => true ,
213
+ 'allowShareDialogUserEnumeration ' => true ,
214
+ 'restrictUserEnumerationToGroup ' => false ,
215
+ 'restrictUserEnumerationToPhone ' => false ,
216
+ 'restrictUserEnumerationFullMatch ' => true ,
217
+ 'restrictUserEnumerationFullMatchUserId ' => true ,
218
+ 'restrictUserEnumerationFullMatchEmail ' => true ,
219
+ 'restrictUserEnumerationFullMatchIgnoreSecondDN ' => false ,
220
+ 'enforceLinksPassword ' => false ,
221
+ 'onlyShareWithGroupMembers ' => false ,
222
+ 'enabled ' => true ,
223
+ 'defaultExpireDate ' => false ,
224
+ 'expireAfterNDays ' => '7 ' ,
225
+ 'enforceExpireDate ' => false ,
226
+ 'excludeGroups ' => 'yes ' ,
227
+ 'excludeGroupsList ' => ['NoSharers ' ,'OtherNoSharers ' ],
228
+ 'publicShareDisclaimerText ' => 'Lorem ipsum ' ,
229
+ 'enableLinkPasswordByDefault ' => true ,
230
+ 'defaultPermissions ' => Constants::PERMISSION_ALL ,
231
+ 'defaultInternalExpireDate ' => false ,
232
+ 'internalExpireAfterNDays ' => '7 ' ,
233
+ 'enforceInternalExpireDate ' => false ,
234
+ 'defaultRemoteExpireDate ' => false ,
235
+ 'remoteExpireAfterNDays ' => '7 ' ,
236
+ 'enforceRemoteExpireDate ' => false ,
237
+ 'allowLinksExcludeGroups ' => [],
238
+ 'onlyShareWithGroupMembersExcludeGroupList ' => [],
239
+ 'enforceLinksPasswordExcludedGroups ' => [],
240
+ 'enforceLinksPasswordExcludedGroupsEnabled ' => false ,
241
+ ],
242
+ ];
238
243
239
244
$ expected = new TemplateResponse (
240
245
'settings ' ,
@@ -244,6 +249,7 @@ public function testGetFormWithExcludedGroups(): void {
244
249
);
245
250
246
251
$ this ->assertEquals ($ expected , $ this ->admin ->getForm ());
252
+ $ this ->assertEquals (sort ($ expectedInitialStateCalls ), sort ($ initialStateCalls ), 'Provided initial state does not match ' );
247
253
}
248
254
249
255
public function testGetSection (): void {
0 commit comments