@@ -247,48 +247,38 @@ public function testPublishNewSharedSubmission(int $shareType, string $shareWith
247247 $ form ->setOwnerId ('formOwner ' );
248248 $ submitterId = 'submittingUser ' ;
249249
250- if ($ shareType === IShare::TYPE_CIRCLE ) {
251- $ this ->circlesService ->expects ($ this ->once ())
252- ->method ('getCircleUsers ' )
253- ->with ('sharedCircle ' )
254- ->willReturn ($ sharedUsers );
255- } elseif ($ shareType === IShare::TYPE_GROUP ) {
256- $ users = array_map (function ($ name ) {
257- $ user = $ this ->createMock (IUser::class);
258- $ user ->expects ($ this ->once ())->method ('getUID ' )->willReturn ($ name );
259- return $ user ;
260- }, $ sharedUsers );
261- $ group = $ this ->createMock (IGroup::class);
262- $ group ->expects ($ this ->once ())->method ('getUsers ' )->willReturn ($ users );
263- $ this ->groupManager ->expects ($ this ->once ())->method ('get ' )->willReturn ($ group );
264- }
265-
266250 $ event = $ this ->createMock (IEvent::class);
267- $ this ->manager ->expects ($ this ->exactly (count ($ expected )))
251+ $ expectedCount = count ($ sharedUsers ?? []);
252+
253+ $ this ->manager ->expects ($ this ->exactly ($ expectedCount ))
268254 ->method ('generateEvent ' )
269255 ->willReturn ($ event );
270- $ event ->expects ($ this ->exactly (count ( $ expected ) ))->method ('setApp ' )->with ('forms ' )->willReturn ($ event );
271- $ event ->expects ($ this ->exactly (count ( $ expected ) ))->method ('setType ' )->with ('forms_newsharedsubmission ' )->willReturn ($ event );
272- $ event ->expects ($ this ->exactly (count ( $ expected ) ))->method ('setAuthor ' )->with ('submittingUser ' )->willReturn ($ event );
273- $ event ->expects ($ this ->exactly (count ( $ expected ) ))->method ('setObject ' )->with ('form ' , 5 )->willReturn ($ event );
274- $ event ->expects ($ this ->exactly (count ( $ expected ) ))->method ('setSubject ' )->with ('newsubmission ' , [
256+ $ event ->expects ($ this ->exactly ($ expectedCount ))->method ('setApp ' )->with ('forms ' )->willReturn ($ event );
257+ $ event ->expects ($ this ->exactly ($ expectedCount ))->method ('setType ' )->with ('forms_newsharedsubmission ' )->willReturn ($ event );
258+ $ event ->expects ($ this ->exactly ($ expectedCount ))->method ('setAuthor ' )->with ('submittingUser ' )->willReturn ($ event );
259+ $ event ->expects ($ this ->exactly ($ expectedCount ))->method ('setObject ' )->with ('form ' , 5 )->willReturn ($ event );
260+ $ event ->expects ($ this ->exactly ($ expectedCount ))->method ('setSubject ' )->with ('newsubmission ' , [
275261 'userId ' => 'submittingUser ' ,
276262 'formTitle ' => 'TestForm-Title ' ,
277263 'formHash ' => 'abcdefg12345 '
278264 ])->willReturn ($ event );
279265 $ affectedUsers = [];
280- $ event ->expects ($ this ->exactly (count ( $ sharedUsers ) ))
266+ $ event ->expects ($ this ->exactly ($ expectedCount ))
281267 ->method ('setAffectedUser ' )
282268 ->willReturnCallback (function (string $ userId ) use (&$ affectedUsers , &$ event ) {
283269 $ affectedUsers [] = $ userId ;
284270 return $ event ;
285271 });
286272
287- $ this ->manager ->expects ($ this ->exactly (count ( $ expected ) ))
273+ $ this ->manager ->expects ($ this ->exactly ($ expectedCount ))
288274 ->method ('publish ' )
289275 ->with ($ event );
290276
291- $ this ->activityManager ->publishNewSharedSubmission ($ form , $ shareType , $ shareWith , $ submitterId );
292- $ this ->assertEquals ($ sharedUsers , $ affectedUsers );
277+ // Call per-user publisher for each expected shared user (new API)
278+ foreach ($ sharedUsers ?? [] as $ userId ) {
279+ $ this ->activityManager ->publishNewSharedSubmission ($ form , $ userId , $ submitterId );
280+ }
281+
282+ $ this ->assertEquals ($ sharedUsers ?? [], $ affectedUsers );
293283 }
294284}
0 commit comments