@@ -126,6 +126,10 @@ public function testDeliveryNoSignificantChange(): void {
126126 $ message ->senderName = 'Mr. Wizard ' ;
127127 $ message->
recipient =
'mailto: ' .
'[email protected] ' ;
128128 $ message ->significantChange = false ;
129+
130+ $ this ->config ->expects (self ::never ())
131+ ->method ('getValueBool ' );
132+
129133 $ this ->plugin ->schedule ($ message );
130134 $ this ->assertEquals ('1.0 ' , $ message ->getScheduleStatus ());
131135 }
@@ -173,6 +177,12 @@ public function testParsingSingle(): void {
173177 $ this ->service ->expects (self ::once ())
174178 ->method ('getLastOccurrence ' )
175179 ->willReturn (1496912700 );
180+ $ this ->config ->expects (self ::exactly (2 ))
181+ ->method ('getValueBool ' )
182+ ->willReturnMap ([
183+ ['dav ' , 'caldav_external_attendees_disabled ' , false , false ],
184+ ['core ' , 'mail_providers_enabled ' , true , false ],
185+ ]);
176186 $ this ->mailer ->expects (self ::once ())
177187 ->method ('validateMailAddress ' )
178188@@ -280,6 +290,10 @@ public function testAttendeeIsResource(): void {
280290 $ this ->service ->expects (self ::once ())
281291 ->method ('getLastOccurrence ' )
282292 ->willReturn (1496912700 );
293+ $ this ->config ->expects (self ::once ())
294+ ->method ('getValueBool ' )
295+ ->with ('dav ' , 'caldav_external_attendees_disabled ' , false )
296+ ->willReturn (false );
283297 $ this ->mailer ->expects (self ::once ())
284298 ->method ('validateMailAddress ' )
285299@@ -358,6 +372,10 @@ public function testAttendeeIsCircle(): void {
358372 $ this ->service ->expects (self ::once ())
359373 ->method ('getLastOccurrence ' )
360374 ->willReturn (1496912700 );
375+ $ this ->config ->expects (self ::once ())
376+ ->method ('getValueBool ' )
377+ ->with ('dav ' , 'caldav_external_attendees_disabled ' , false )
378+ ->willReturn (false );
361379 $ this ->mailer ->expects (self ::once ())
362380 ->method ('validateMailAddress ' )
363381@@ -463,6 +481,12 @@ public function testParsingRecurrence(): void {
463481 $ this ->service ->expects (self ::once ())
464482 ->method ('getLastOccurrence ' )
465483 ->willReturn (1496912700 );
484+ $ this ->config ->expects (self ::exactly (2 ))
485+ ->method ('getValueBool ' )
486+ ->willReturnMap ([
487+ ['dav ' , 'caldav_external_attendees_disabled ' , false , false ],
488+ ['core ' , 'mail_providers_enabled ' , true , false ],
489+ ]);
466490 $ this ->mailer ->expects (self ::once ())
467491 ->method ('validateMailAddress ' )
468492@@ -715,6 +739,12 @@ public function testMailProviderSend(): void {
715739 $ this ->service ->expects (self ::once ())
716740 ->method ('getLastOccurrence ' )
717741 ->willReturn (1496912700 );
742+ $ this ->config ->expects (self ::exactly (2 ))
743+ ->method ('getValueBool ' )
744+ ->willReturnMap ([
745+ ['dav ' , 'caldav_external_attendees_disabled ' , false , false ],
746+ ['core ' , 'mail_providers_enabled ' , true , true ],
747+ ]);
718748 $ this ->service ->expects (self ::once ())
719749 ->method ('getCurrentAttendee ' )
720750 ->with ($ message )
@@ -866,10 +896,12 @@ public function testMailProviderDisabled(): void {
866896 ->method ('getValueString ' )
867897 ->with ('dav ' , 'invitation_link_recipients ' , 'yes ' )
868898 ->willReturn ('yes ' );
869- $ this ->config ->expects (self ::once ( ))
899+ $ this ->config ->expects (self ::exactly ( 2 ))
870900 ->method ('getValueBool ' )
871- ->with ('core ' , 'mail_providers_enabled ' , true )
872- ->willReturn (false );
901+ ->willReturnMap ([
902+ ['dav ' , 'caldav_external_attendees_disabled ' , false , false ],
903+ ['core ' , 'mail_providers_enabled ' , true , false ],
904+ ]);
873905 $ this ->service ->expects (self ::once ())
874906 ->method ('createInvitationToken ' )
875907 ->with ($ message , $ newVevent , 1496912700 )
@@ -917,6 +949,12 @@ public function testNoOldEvent(): void {
917949 $ this ->service ->expects (self ::once ())
918950 ->method ('getLastOccurrence ' )
919951 ->willReturn (1496912700 );
952+ $ this ->config ->expects (self ::exactly (2 ))
953+ ->method ('getValueBool ' )
954+ ->willReturnMap ([
955+ ['dav ' , 'caldav_external_attendees_disabled ' , false , false ],
956+ ['core ' , 'mail_providers_enabled ' , true , false ],
957+ ]);
920958 $ this ->mailer ->expects (self ::once ())
921959 ->method ('validateMailAddress ' )
922960@@ -1014,6 +1052,12 @@ public function testNoButtons(): void {
10141052 $ this ->service ->expects (self ::once ())
10151053 ->method ('getLastOccurrence ' )
10161054 ->willReturn (1496912700 );
1055+ $ this ->config ->expects (self ::exactly (2 ))
1056+ ->method ('getValueBool ' )
1057+ ->willReturnMap ([
1058+ ['dav ' , 'caldav_external_attendees_disabled ' , false , false ],
1059+ ['core ' , 'mail_providers_enabled ' , true , false ],
1060+ ]);
10171061 $ this ->mailer ->expects (self ::once ())
10181062 ->method ('validateMailAddress ' )
10191063@@ -1077,4 +1121,156 @@ public function testNoButtons(): void {
10771121 $ this ->plugin ->schedule ($ message );
10781122 $ this ->assertEquals ('1.1 ' , $ message ->getScheduleStatus ());
10791123 }
1124+
1125+ public function testExternalAttendeesDisabledForExternalUser (): void {
1126+ $ message = new Message ();
1127+ $ message ->method = 'REQUEST ' ;
1128+ $ newVCalendar = new VCalendar ();
1129+ $ newVevent = new VEvent ($ newVCalendar , 'one ' , array_merge ([
1130+ 'UID ' => 'uid-1234 ' ,
1131+ 'SEQUENCE ' => 1 ,
1132+ 'SUMMARY ' => 'Fellowship meeting ' ,
1133+ 'DTSTART ' => new \DateTime ('2016-01-01 00:00:00 ' )
1134+ ], []));
1135+ $ newVevent->
add (
'ORGANIZER ' ,
'mailto:[email protected] ' );
1136+ $ newVevent->
add (
'ATTENDEE ' ,
'mailto:[email protected] ' , [
'RSVP ' =>
'TRUE ' ,
'CN ' =>
'External User ' ]);
1137+ $ message ->message = $ newVCalendar ;
1138+ $ message->
sender =
'mailto:[email protected] ' ;
1139+ $ message ->senderName = 'Mr. Wizard ' ;
1140+ $ message->
recipient =
'mailto:[email protected] ' ;
1141+
1142+ $ this ->service ->expects (self ::once ())
1143+ ->method ('getLastOccurrence ' )
1144+ ->willReturn (1496912700 );
1145+ $ this ->config ->expects (self ::once ())
1146+ ->method ('getValueBool ' )
1147+ ->with ('dav ' , 'caldav_external_attendees_disabled ' , false )
1148+ ->willReturn (true );
1149+ $ this ->service ->expects (self ::once ())
1150+ ->method ('isSystemUser ' )
1151+ 1152+ ->willReturn (false );
1153+ $ this ->eventComparisonService ->expects (self ::never ())
1154+ ->method ('findModified ' );
1155+ $ this ->service ->expects (self ::never ())
1156+ ->method ('getCurrentAttendee ' );
1157+ $ this ->mailer ->expects (self ::never ())
1158+ ->method ('send ' );
1159+
1160+ $ this ->plugin ->schedule ($ message );
1161+ $ this ->assertEquals ('5.0 ' , $ message ->getScheduleStatus ());
1162+ }
1163+
1164+ public function testExternalAttendeesDisabledForSystemUser (): void {
1165+ $ message = new Message ();
1166+ $ message ->method = 'REQUEST ' ;
1167+ $ newVCalendar = new VCalendar ();
1168+ $ newVevent = new VEvent ($ newVCalendar , 'one ' , array_merge ([
1169+ 'UID ' => 'uid-1234 ' ,
1170+ 'SEQUENCE ' => 1 ,
1171+ 'SUMMARY ' => 'Fellowship meeting ' ,
1172+ 'DTSTART ' => new \DateTime ('2016-01-01 00:00:00 ' )
1173+ ], []));
1174+ $ newVevent->
add (
'ORGANIZER ' ,
'mailto:[email protected] ' );
1175+ $ newVevent->
add (
'ATTENDEE ' ,
'mailto:[email protected] ' , [
'RSVP ' =>
'TRUE ' ,
'CN ' =>
'Frodo ' ]);
1176+ $ message ->message = $ newVCalendar ;
1177+ $ message->
sender =
'mailto:[email protected] ' ;
1178+ $ message ->senderName = 'Mr. Wizard ' ;
1179+ $ message->
recipient =
'mailto:[email protected] ' ;
1180+
1181+ $ oldVCalendar = new VCalendar ();
1182+ $ oldVEvent = new VEvent ($ oldVCalendar , 'one ' , [
1183+ 'UID ' => 'uid-1234 ' ,
1184+ 'SEQUENCE ' => 0 ,
1185+ 'SUMMARY ' => 'Fellowship meeting ' ,
1186+ 'DTSTART ' => new \DateTime ('2016-01-01 00:00:00 ' )
1187+ ]);
1188+ $ oldVEvent->
add (
'ORGANIZER ' ,
'mailto:[email protected] ' );
1189+ $ oldVEvent->
add (
'ATTENDEE ' ,
'mailto:[email protected] ' , [
'RSVP ' =>
'TRUE ' ,
'CN ' =>
'Frodo ' ]);
1190+ $ oldVCalendar ->add ($ oldVEvent );
1191+
1192+ $ data = ['invitee_name ' => 'Mr. Wizard ' ,
1193+ 'meeting_title ' => 'Fellowship meeting ' ,
1194+ 'attendee_name ' =>
'[email protected] ' 1195+ ];
1196+ $ attendees = $ newVevent ->select ('ATTENDEE ' );
1197+ $ atnd = '' ;
1198+ foreach ($ attendees as $ attendee ) {
1199+ if (strcasecmp ($ attendee ->getValue (), $ message ->recipient ) === 0 ) {
1200+ $ atnd = $ attendee ;
1201+ }
1202+ }
1203+ $ this ->plugin ->setVCalendar ($ oldVCalendar );
1204+ $ this ->service ->expects (self ::once ())
1205+ ->method ('getLastOccurrence ' )
1206+ ->willReturn (1496912700 );
1207+ $ this ->config ->expects (self ::exactly (2 ))
1208+ ->method ('getValueBool ' )
1209+ ->willReturnMap ([
1210+ ['dav ' , 'caldav_external_attendees_disabled ' , false , true ],
1211+ ['core ' , 'mail_providers_enabled ' , true , false ],
1212+ ]);
1213+ $ this ->service ->expects (self ::once ())
1214+ ->method ('isSystemUser ' )
1215+ 1216+ ->willReturn (true );
1217+ $ this ->eventComparisonService ->expects (self ::once ())
1218+ ->method ('findModified ' )
1219+ ->willReturn (['new ' => [$ newVevent ], 'old ' => [$ oldVEvent ]]);
1220+ $ this ->service ->expects (self ::once ())
1221+ ->method ('getCurrentAttendee ' )
1222+ ->with ($ message )
1223+ ->willReturn ($ atnd );
1224+ $ this ->service ->expects (self ::once ())
1225+ ->method ('isRoomOrResource ' )
1226+ ->with ($ atnd )
1227+ ->willReturn (false );
1228+ $ this ->service ->expects (self ::once ())
1229+ ->method ('isCircle ' )
1230+ ->with ($ atnd )
1231+ ->willReturn (false );
1232+ $ this ->service ->expects (self ::once ())
1233+ ->method ('buildBodyData ' )
1234+ ->with ($ newVevent , $ oldVEvent )
1235+ ->willReturn ($ data );
1236+ $ this ->user ->expects (self ::any ())
1237+ ->method ('getUID ' )
1238+ ->willReturn ('user1 ' );
1239+ $ this ->user ->expects (self ::any ())
1240+ ->method ('getDisplayName ' )
1241+ ->willReturn ('Mr. Wizard ' );
1242+ $ this ->userSession ->expects (self ::any ())
1243+ ->method ('getUser ' )
1244+ ->willReturn ($ this ->user );
1245+ $ this ->service ->expects (self ::once ())
1246+ ->method ('getFrom ' );
1247+ $ this ->service ->expects (self ::once ())
1248+ ->method ('addSubjectAndHeading ' )
1249+ ->with ($ this ->emailTemplate , 'request ' , 'Mr. Wizard ' , 'Fellowship meeting ' , true );
1250+ $ this ->service ->expects (self ::once ())
1251+ ->method ('addBulletList ' )
1252+ ->with ($ this ->emailTemplate , $ newVevent , $ data );
1253+ $ this ->service ->expects (self ::once ())
1254+ ->method ('getAttendeeRsvpOrReqForParticipant ' )
1255+ ->willReturn (true );
1256+ $ this ->config ->expects (self ::once ())
1257+ ->method ('getValueString ' )
1258+ ->with ('dav ' , 'invitation_link_recipients ' , 'yes ' )
1259+ ->willReturn ('yes ' );
1260+ $ this ->service ->expects (self ::once ())
1261+ ->method ('createInvitationToken ' )
1262+ ->with ($ message , $ newVevent , 1496912700 )
1263+ ->willReturn ('token ' );
1264+ $ this ->service ->expects (self ::once ())
1265+ ->method ('addResponseButtons ' )
1266+ ->with ($ this ->emailTemplate , 'token ' );
1267+ $ this ->service ->expects (self ::once ())
1268+ ->method ('addMoreOptionsButton ' )
1269+ ->with ($ this ->emailTemplate , 'token ' );
1270+ $ this ->mailer ->expects (self ::once ())
1271+ ->method ('send ' )
1272+ ->willReturn ([]);
1273+ $ this ->plugin ->schedule ($ message );
1274+ $ this ->assertEquals ('1.1 ' , $ message ->getScheduleStatus ());
1275+ }
10801276}
0 commit comments