@@ -161,7 +161,7 @@ public function testNoCalendars(): void {
161161 ->method ('getDateTime ' );
162162 $ this ->calendarManager ->expects (self ::never ())
163163 ->method ('searchForPrincipal ' );
164- $ this ->userStatusService ->expects (self ::once ( ))
164+ $ this ->userStatusService ->expects (self ::exactly ( 2 ))
165165 ->method ('revertUserStatus ' );
166166 $ this ->logger ->expects (self ::once ())
167167 ->method ('debug ' );
@@ -203,7 +203,7 @@ public function testNoCalendarEvents(): void {
203203 $ this ->calendarManager ->expects (self ::once ())
204204 ->method ('searchForPrincipal ' )
205205 ->willReturn ([]);
206- $ this ->userStatusService ->expects (self ::once ( ))
206+ $ this ->userStatusService ->expects (self ::exactly ( 2 ))
207207 ->method ('revertUserStatus ' );
208208 $ this ->logger ->expects (self ::once ())
209209 ->method ('debug ' );
@@ -248,7 +248,7 @@ public function testCalendarNoEventObjects(): void {
248248 $ this ->calendarManager ->expects (self ::once ())
249249 ->method ('searchForPrincipal ' )
250250 ->willReturn ([['objects ' => []]]);
251- $ this ->userStatusService ->expects (self ::once ( ))
251+ $ this ->userStatusService ->expects (self ::exactly ( 2 ))
252252 ->method ('revertUserStatus ' );
253253 $ this ->logger ->expects (self ::once ())
254254 ->method ('debug ' );
@@ -296,7 +296,99 @@ public function testCalendarEvent(): void {
296296 $ this ->logger ->expects (self ::once ())
297297 ->method ('debug ' );
298298 $ this ->userStatusService ->expects (self ::once ())
299- ->method ('setUserStatus ' );
299+ ->method ('setUserStatus ' )
300+ ->with ('admin ' , IUserStatus::BUSY , IUserStatus::MESSAGE_CALENDAR_BUSY_SINGLE , true );
301+
302+ $ this ->service ->processCalendarStatus ('admin ' );
303+ }
304+
305+ public function testCalendarEventWithAttendees (): void {
306+ $ user = $ this ->createConfiguredMock (IUser::class, [
307+ 'getUID ' => 'admin ' ,
308+ ]);
309+
310+ $ this ->userManager ->expects (self ::once ())
311+ ->method ('get ' )
312+ ->willReturn ($ user );
313+ $ this ->availabilityCoordinator ->expects (self ::once ())
314+ ->method ('getCurrentOutOfOfficeData ' )
315+ ->willReturn (null );
316+ $ this ->availabilityCoordinator ->expects (self ::never ())
317+ ->method ('isInEffect ' );
318+ $ this ->cache ->expects (self ::once ())
319+ ->method ('get ' )
320+ ->willReturn (null );
321+ $ this ->cache ->expects (self ::once ())
322+ ->method ('set ' );
323+ $ this ->calendarManager ->expects (self ::once ())
324+ ->method ('getCalendarsForPrincipal ' )
325+ ->willReturn ([$ this ->createMock (CalendarImpl::class)]);
326+ $ this ->calendarManager ->expects (self ::once ())
327+ ->method ('newQuery ' )
328+ ->willReturn (new CalendarQuery ('admin ' ));
329+ $ this ->timeFactory ->expects (self ::exactly (2 ))
330+ ->method ('getDateTime ' )
331+ ->willReturn (new \DateTime ());
332+ $ this ->userStatusService ->expects (self ::once ())
333+ ->method ('findByUserId ' )
334+ ->willThrowException (new DoesNotExistException ('' ));
335+ $ this ->calendarManager ->expects (self ::once ())
336+ ->method ('searchForPrincipal ' )
337+ ->willReturn ([['objects ' => [['ATTENDEE ' => [['mailto:other@example.com ' , []]]]]]]);
338+ $ this ->userStatusService ->expects (self ::never ())
339+ ->method ('revertUserStatus ' );
340+ $ this ->logger ->expects (self ::once ())
341+ ->method ('debug ' );
342+ $ this ->userStatusService ->expects (self ::once ())
343+ ->method ('setUserStatus ' )
344+ ->with ('admin ' , IUserStatus::BUSY , IUserStatus::MESSAGE_CALENDAR_BUSY , true );
345+
346+ $ this ->service ->processCalendarStatus ('admin ' );
347+ }
348+
349+ public function testCalendarEventMeetingTakesPriorityOverSingle (): void {
350+ $ user = $ this ->createConfiguredMock (IUser::class, [
351+ 'getUID ' => 'admin ' ,
352+ ]);
353+
354+ $ this ->userManager ->expects (self ::once ())
355+ ->method ('get ' )
356+ ->willReturn ($ user );
357+ $ this ->availabilityCoordinator ->expects (self ::once ())
358+ ->method ('getCurrentOutOfOfficeData ' )
359+ ->willReturn (null );
360+ $ this ->availabilityCoordinator ->expects (self ::never ())
361+ ->method ('isInEffect ' );
362+ $ this ->cache ->expects (self ::once ())
363+ ->method ('get ' )
364+ ->willReturn (null );
365+ $ this ->cache ->expects (self ::once ())
366+ ->method ('set ' );
367+ $ this ->calendarManager ->expects (self ::once ())
368+ ->method ('getCalendarsForPrincipal ' )
369+ ->willReturn ([$ this ->createMock (CalendarImpl::class)]);
370+ $ this ->calendarManager ->expects (self ::once ())
371+ ->method ('newQuery ' )
372+ ->willReturn (new CalendarQuery ('admin ' ));
373+ $ this ->timeFactory ->expects (self ::exactly (2 ))
374+ ->method ('getDateTime ' )
375+ ->willReturn (new \DateTime ());
376+ $ this ->userStatusService ->expects (self ::once ())
377+ ->method ('findByUserId ' )
378+ ->willThrowException (new DoesNotExistException ('' ));
379+ $ this ->calendarManager ->expects (self ::once ())
380+ ->method ('searchForPrincipal ' )
381+ ->willReturn ([
382+ ['objects ' => [[]]],
383+ ['objects ' => [['ATTENDEE ' => [['mailto:other@example.com ' , []]]]]],
384+ ]);
385+ $ this ->userStatusService ->expects (self ::never ())
386+ ->method ('revertUserStatus ' );
387+ $ this ->logger ->expects (self ::once ())
388+ ->method ('debug ' );
389+ $ this ->userStatusService ->expects (self ::once ())
390+ ->method ('setUserStatus ' )
391+ ->with ('admin ' , IUserStatus::BUSY , IUserStatus::MESSAGE_CALENDAR_BUSY , true );
300392
301393 $ this ->service ->processCalendarStatus ('admin ' );
302394 }
0 commit comments