@@ -78,28 +78,7 @@ protected function setUp(): void {
7878 }
7979
8080 public function testSendWithoutAttendees ():void {
81- $ user1 = $ this ->createMock (IUser::class);
82- $ user1 ->method ('getUID ' )
83- ->willReturn ('uid1 ' );
84- $ user1 ->method ('getEMailAddress ' )
85- ->
willReturn (
'[email protected] ' );
86- $ user2 = $ this ->createMock (IUser::class);
87- $ user2 ->method ('getUID ' )
88- ->willReturn ('uid2 ' );
89- $ user2 ->method ('getEMailAddress ' )
90- ->
willReturn (
'[email protected] ' );
91- $ user3 = $ this ->createMock (IUser::class);
92- $ user3 ->method ('getUID ' )
93- ->willReturn ('uid3 ' );
94- $ user3 ->method ('getEMailAddress ' )
95- ->
willReturn (
'[email protected] ' );
96- $ user4 = $ this ->createMock (IUser::class);
97- $ user4 ->method ('getUID ' )
98- ->willReturn ('uid4 ' );
99- $ user4 ->method ('getEMailAddress ' )
100- ->willReturn (null );
101-
102- $ users = [$ user1 , $ user2 , $ user3 , $ user4 ];
81+ list ($ user1 , $ user2 , $ user3 , , $ user5 ) = $ users = $ this ->getUsers ();
10382
10483 $ this ->config ->expects ($ this ->at (0 ))
10584 ->method ('getUserValue ' )
@@ -163,65 +142,64 @@ public function testSendWithoutAttendees():void {
163142 ->willReturn ($ template1 );
164143
165144 $ this ->mailer ->expects ($ this ->at (1 ))
145+ ->method ('validateMailAddress ' )
146+ 147+ ->willReturn (true );
148+
149+ $ this ->mailer ->expects ($ this ->at (2 ))
166150 ->method ('createMessage ' )
167151 ->with ()
168152 ->willReturn ($ message11 );
169- $ this ->mailer ->expects ($ this ->at (2 ))
153+ $ this ->mailer ->expects ($ this ->at (3 ))
170154 ->method ('send ' )
171155 ->with ($ message11 )
172156 ->willReturn ([]);
173157
174- $ this ->mailer ->expects ($ this ->at (3 ))
158+ $ this ->mailer ->expects ($ this ->at (4 ))
175159 ->method ('createEMailTemplate ' )
176160 ->with ('dav.calendarReminder ' )
177161 ->willReturn ($ template2 );
178162
179- $ this ->mailer ->expects ($ this ->at (4 ))
163+ $ this ->mailer ->expects ($ this ->at (5 ))
164+ ->method ('validateMailAddress ' )
165+ 166+ ->willReturn (true );
167+
168+ $ this ->mailer ->expects ($ this ->at (6 ))
180169 ->method ('createMessage ' )
181170 ->with ()
182171 ->willReturn ($ message21 );
183- $ this ->mailer ->expects ($ this ->at (5 ))
172+ $ this ->mailer ->expects ($ this ->at (7 ))
184173 ->method ('send ' )
185174 ->with ($ message21 )
186175 ->willReturn ([]);
187- $ this ->mailer ->expects ($ this ->at (6 ))
176+ $ this ->mailer ->expects ($ this ->at (8 ))
177+ ->method ('validateMailAddress ' )
178+ 179+ ->willReturn (true );
180+
181+ $ this ->mailer ->expects ($ this ->at (9 ))
188182 ->method ('createMessage ' )
189183 ->with ()
190184 ->willReturn ($ message22 );
191- $ this ->mailer ->expects ($ this ->at (7 ))
185+ $ this ->mailer ->expects ($ this ->at (10 ))
192186 ->method ('send ' )
193187 ->with ($ message22 )
194188 ->willReturn ([]);
195189
190+ $ this ->mailer ->expects ($ this ->at (11 ))
191+ ->method ('validateMailAddress ' )
192+ ->with ('invalid ' )
193+ ->willReturn (false );
194+
196195 $ this ->setupURLGeneratorMock (2 );
197196
198197 $ vcalendar = $ this ->getNoAttendeeVCalendar ();
199198 $ this ->provider ->send ($ vcalendar ->VEVENT , $ this ->calendarDisplayName , $ users );
200199 }
201200
202201 public function testSendWithAttendees (): void {
203- $ user1 = $ this ->createMock (IUser::class);
204- $ user1 ->method ('getUID ' )
205- ->willReturn ('uid1 ' );
206- $ user1 ->method ('getEMailAddress ' )
207- ->
willReturn (
'[email protected] ' );
208- $ user2 = $ this ->createMock (IUser::class);
209- $ user2 ->method ('getUID ' )
210- ->willReturn ('uid2 ' );
211- $ user2 ->method ('getEMailAddress ' )
212- ->
willReturn (
'[email protected] ' );
213- $ user3 = $ this ->createMock (IUser::class);
214- $ user3 ->method ('getUID ' )
215- ->willReturn ('uid3 ' );
216- $ user3 ->method ('getEMailAddress ' )
217- ->
willReturn (
'[email protected] ' );
218- $ user4 = $ this ->createMock (IUser::class);
219- $ user4 ->method ('getUID ' )
220- ->willReturn ('uid4 ' );
221- $ user4 ->method ('getEMailAddress ' )
222- ->willReturn (null );
223-
224- $ users = [$ user1 , $ user2 , $ user3 , $ user4 ];
202+ list ($ user1 , $ user2 , $ user3 , , $ user5 ) = $ users = $ this ->getUsers ();
225203
226204 $ this ->config ->expects ($ this ->at (0 ))
227205 ->method ('getUserValue ' )
@@ -288,56 +266,89 @@ public function testSendWithAttendees(): void {
288266 ->willReturn ($ template1 );
289267
290268 $ this ->mailer ->expects ($ this ->at (1 ))
269+ ->method ('validateMailAddress ' )
270+ 271+ ->willReturn (true );
272+
273+ $ this ->mailer ->expects ($ this ->at (2 ))
291274 ->method ('createMessage ' )
292275 ->with ()
293276 ->willReturn ($ message11 );
294- $ this ->mailer ->expects ($ this ->at (2 ))
277+ $ this ->mailer ->expects ($ this ->at (3 ))
295278 ->method ('send ' )
296279 ->with ($ message11 )
297280 ->willReturn ([]);
298- $ this ->mailer ->expects ($ this ->at (3 ))
281+ $ this ->mailer ->expects ($ this ->at (4 ))
282+ ->method ('validateMailAddress ' )
283+ 284+ ->willReturn (true );
285+ $ this ->mailer ->expects ($ this ->at (5 ))
299286 ->method ('createMessage ' )
300287 ->with ()
301288 ->willReturn ($ message12 );
302- $ this ->mailer ->expects ($ this ->at (4 ))
289+ $ this ->mailer ->expects ($ this ->at (6 ))
303290 ->method ('send ' )
304291 ->with ($ message12 )
305292 ->willReturn ([]);
306- $ this ->mailer ->expects ($ this ->at (5 ))
293+
294+ $ this ->mailer ->expects ($ this ->at (7 ))
295+ ->method ('validateMailAddress ' )
296+ 297+ ->willReturn (true );
298+
299+ $ this ->mailer ->expects ($ this ->at (8 ))
307300 ->method ('createMessage ' )
308301 ->with ()
309302 ->willReturn ($ message13 );
310- $ this ->mailer ->expects ($ this ->at (6 ))
303+ $ this ->mailer ->expects ($ this ->at (9 ))
311304 ->method ('send ' )
312305 ->with ($ message13 )
313306 ->willReturn ([]);
314307
315- $ this ->mailer ->expects ($ this ->at (7 ))
308+ $ this ->mailer ->expects ($ this ->at (10 ))
309+ ->method ('validateMailAddress ' )
310+ ->with ('invalid ' )
311+ ->willReturn (false );
312+
313+ $ this ->mailer ->expects ($ this ->at (11 ))
316314 ->method ('createEMailTemplate ' )
317315 ->with ('dav.calendarReminder ' )
318316 ->willReturn ($ template2 );
319317
320- $ this ->mailer ->expects ($ this ->at (8 ))
318+ $ this ->mailer ->expects ($ this ->at (12 ))
319+ ->method ('validateMailAddress ' )
320+ 321+ ->willReturn (true );
322+
323+ $ this ->mailer ->expects ($ this ->at (13 ))
321324 ->method ('createMessage ' )
322325 ->with ()
323326 ->willReturn ($ message21 );
324- $ this ->mailer ->expects ($ this ->at (9 ))
327+ $ this ->mailer ->expects ($ this ->at (14 ))
325328 ->method ('send ' )
326329 ->with ($ message21 )
327330 ->willReturn ([]);
328- $ this ->mailer ->expects ($ this ->at (10 ))
331+ $ this ->mailer ->expects ($ this ->at (15 ))
332+ ->method ('validateMailAddress ' )
333+ 334+ ->willReturn (true );
335+ $ this ->mailer ->expects ($ this ->at (16 ))
329336 ->method ('createMessage ' )
330337 ->with ()
331338 ->willReturn ($ message22 );
332- $ this ->mailer ->expects ($ this ->at (11 ))
339+ $ this ->mailer ->expects ($ this ->at (17 ))
333340 ->method ('send ' )
334341 ->with ($ message22 )
335342 ->willReturn ([]);
336- $ this ->mailer ->expects ($ this ->at (12 ))
343+ $ this ->mailer ->expects ($ this ->at (18 ))
344+ ->method ('validateMailAddress ' )
345+ 346+ ->willReturn (true );
347+ $ this ->mailer ->expects ($ this ->at (19 ))
337348 ->method ('createMessage ' )
338349 ->with ()
339350 ->willReturn ($ message23 );
340- $ this ->mailer ->expects ($ this ->at (13 ))
351+ $ this ->mailer ->expects ($ this ->at (20 ))
341352 ->method ('send ' )
342353 ->with ($ message23 )
343354 ->willReturn ([]);
@@ -398,9 +409,9 @@ private function getTemplateMock():IEMailTemplate {
398409 }
399410
400411 /**
401- * @param array $toMail
412+ * @param string $toMail
402413 * @param IEMailTemplate $templateMock
403- * @param array $replyTo
414+ * @param array|null $replyTo
404415 * @return IMessage
405416 */
406417 private function getMessageMock (string $ toMail , IEMailTemplate $ templateMock , array $ replyTo =null ):IMessage {
@@ -546,4 +557,34 @@ private function setupURLGeneratorMock(int $times=1):void {
546557 ->willReturn ('AbsURL4 ' );
547558 }
548559 }
560+
561+ private function getUsers (): array {
562+ $ user1 = $ this ->createMock (IUser::class);
563+ $ user1 ->method ('getUID ' )
564+ ->willReturn ('uid1 ' );
565+ $ user1 ->method ('getEMailAddress ' )
566+ ->
willReturn (
'[email protected] ' );
567+ $ user2 = $ this ->createMock (IUser::class);
568+ $ user2 ->method ('getUID ' )
569+ ->willReturn ('uid2 ' );
570+ $ user2 ->method ('getEMailAddress ' )
571+ ->
willReturn (
'[email protected] ' );
572+ $ user3 = $ this ->createMock (IUser::class);
573+ $ user3 ->method ('getUID ' )
574+ ->willReturn ('uid3 ' );
575+ $ user3 ->method ('getEMailAddress ' )
576+ ->
willReturn (
'[email protected] ' );
577+ $ user4 = $ this ->createMock (IUser::class);
578+ $ user4 ->method ('getUID ' )
579+ ->willReturn ('uid4 ' );
580+ $ user4 ->method ('getEMailAddress ' )
581+ ->willReturn (null );
582+ $ user5 = $ this ->createMock (IUser::class);
583+ $ user5 ->method ('getUID ' )
584+ ->willReturn ('uid5 ' );
585+ $ user5 ->method ('getEMailAddress ' )
586+ ->willReturn ('invalid ' );
587+
588+ return [$ user1 , $ user2 , $ user3 , $ user4 , $ user5 ];
589+ }
549590}
0 commit comments