Passed
Push — master ( ebdfbb...20570e )
by
unknown
02:32
created

UserDefinedFormTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SilverStripe\UserForms\Tests\Model;
4
5
use SilverStripe\Control\Controller;
6
use SilverStripe\Control\Email\Email;
7
use SilverStripe\Core\Convert;
8
use SilverStripe\Dev\FunctionalTest;
9
use SilverStripe\Forms\DropdownField;
10
use SilverStripe\Forms\FieldList;
11
use SilverStripe\Forms\Form;
12
use SilverStripe\Forms\GridField\GridField;
13
use SilverStripe\Forms\GridField\GridFieldDataColumns;
14
use SilverStripe\ORM\DB;
15
use SilverStripe\UserForms\Extension\UserFormFieldEditorExtension;
16
use SilverStripe\UserForms\Extension\UserFormValidator;
17
use SilverStripe\UserForms\Model\EditableCustomRule;
18
use SilverStripe\UserForms\Model\EditableFormField;
19
use SilverStripe\UserForms\Model\EditableFormField\EditableDropdown;
20
use SilverStripe\UserForms\Model\EditableFormField\EditableEmailField;
21
use SilverStripe\UserForms\Model\EditableFormField\EditableFieldGroup;
22
use SilverStripe\UserForms\Model\EditableFormField\EditableFieldGroupEnd;
23
use SilverStripe\UserForms\Model\Recipient\EmailRecipient;
24
use SilverStripe\UserForms\Model\UserDefinedForm;
25
use SilverStripe\Versioned\Versioned;
26
27
/**
28
 * @package userforms
29
 */
30
class UserDefinedFormTest extends FunctionalTest
31
{
32
    protected static $fixture_file = '../UserFormsTest.yml';
33
34
    protected static $required_extensions = [
35
        UserDefinedForm::class => [UserFormFieldEditorExtension::class],
36
    ];
37
38
    protected function setUp()
39
    {
40
        parent::setUp();
41
        Email::config()->update('admin_email', '[email protected]');
42
    }
43
44
    public function testRollbackToVersion()
45
    {
46
        $this->markTestSkipped(
47
            'UserDefinedForm::rollback() has not been implemented completely'
48
        );
49
50
        // @todo
51
        $this->logInWithPermission('ADMIN');
52
        $form = $this->objFromFixture(UserDefinedForm::class, 'basic-form-page');
53
54
        $form->SubmitButtonText = 'Button Text';
55
        $form->write();
56
        $form->publishRecursive();
57
        $origVersion = $form->Version;
58
59
        $form->SubmitButtonText = 'Updated Button Text';
60
        $form->write();
61
        $form->publishRecursive();
62
63
        // check published site
64
        $updated = Versioned::get_one_by_stage(UserDefinedForm::class, 'Stage', "\"UserDefinedForm\".\"ID\" = $form->ID");
65
        $this->assertEquals($updated->SubmitButtonText, 'Updated Button Text');
66
67
        $form->doRollbackTo($origVersion);
68
69
        $orignal = Versioned::get_one_by_stage(UserDefinedForm::class, 'Stage', "\"UserDefinedForm\".\"ID\" = $form->ID");
70
        $this->assertEquals($orignal->SubmitButtonText, 'Button Text');
71
    }
72
73
    public function testGetCMSFields()
74
    {
75
        $this->logInWithPermission('ADMIN');
76
        $form = $this->objFromFixture(UserDefinedForm::class, 'basic-form-page');
77
78
        $fields = $form->getCMSFields();
79
80
        $this->assertNotNull($fields->dataFieldByName('Fields'));
81
        $this->assertNotNull($fields->dataFieldByName('EmailRecipients'));
82
        $this->assertNotNull($fields->dataFieldByName('Submissions'));
83
        $this->assertNotNull($fields->dataFieldByName('OnCompleteMessage'));
84
    }
85
86
87
    public function testGetCMSFieldsShowInSummary()
88
    {
89
        $this->logInWithPermission('ADMIN');
90
        $form = $this->objFromFixture(UserDefinedForm::class, 'summary-rules-form');
91
92
        $fields = $form->getCMSFields();
93
94
        $this->assertInstanceOf(GridField::class, $fields->dataFieldByName('Submissions'));
95
96
        $submissionsgrid = $fields->dataFieldByName('Submissions');
97
        $gridFieldDataColumns = $submissionsgrid->getConfig()->getComponentByType(GridFieldDataColumns::class);
98
99
        $summaryFields = $gridFieldDataColumns->getDisplayFields($submissionsgrid);
100
101
        $this->assertContains('SummaryShow', array_keys($summaryFields), 'Summary field not showing displayed field');
102
        $this->assertNotContains('SummaryHide', array_keys($summaryFields), 'Summary field showing displayed field');
103
    }
104
105
106
    public function testEmailRecipientPopup()
107
    {
108
        $this->logInWithPermission('ADMIN');
109
110
        $form = $this->objFromFixture(UserDefinedForm::class, 'basic-form-page');
111
112
        $popup = new EmailRecipient();
113
        $popup->FormID = $form->ID;
0 ignored issues
show
Bug Best Practice introduced by
The property FormID does not exist on SilverStripe\UserForms\M...ecipient\EmailRecipient. Since you implemented __set, consider adding a @property annotation.
Loading history...
114
115
        $fields = $popup->getCMSFields();
116
117
        $this->assertNotNull($fields->dataFieldByName('EmailSubject'));
118
        $this->assertNotNull($fields->dataFieldByName('EmailFrom'));
119
        $this->assertNotNull($fields->dataFieldByName('EmailAddress'));
120
        $this->assertNotNull($fields->dataFieldByName('HideFormData'));
121
        $this->assertNotNull($fields->dataFieldByName('SendPlain'));
122
        $this->assertNotNull($fields->dataFieldByName('EmailBody'));
123
124
        // add an email field, it should now add a or from X address picker
125
        $email = $this->objFromFixture(EditableEmailField::class, 'email-field');
126
        $form->Fields()->add($email);
127
128
        $popup->write();
129
130
        $fields = $popup->getCMSFields();
131
        $this->assertThat($fields->dataFieldByName('SendEmailToFieldID'), $this->isInstanceOf(DropdownField::class));
132
133
        // if the front end has checkboxs or dropdown they can select from that can also be used to send things
134
        $dropdown = $this->objFromFixture(EditableDropdown::class, 'department-dropdown');
135
        $form->Fields()->add($dropdown);
136
137
        $fields = $popup->getCMSFields();
138
        $this->assertTrue($fields->dataFieldByName('SendEmailToFieldID') !== null);
139
140
        $popup->delete();
141
    }
142
143
    public function testGetEmailBodyContent()
144
    {
145
        $recipient = new EmailRecipient();
146
147
        $emailBody = 'not html';
148
        $emailBodyHtml = '<p>html</p>';
149
150
        $recipient->EmailBody = $emailBody;
0 ignored issues
show
Bug Best Practice introduced by
The property EmailBody does not exist on SilverStripe\UserForms\M...ecipient\EmailRecipient. Since you implemented __set, consider adding a @property annotation.
Loading history...
151
        $recipient->EmailBodyHtml = $emailBodyHtml;
0 ignored issues
show
Bug Best Practice introduced by
The property EmailBodyHtml does not exist on SilverStripe\UserForms\M...ecipient\EmailRecipient. Since you implemented __set, consider adding a @property annotation.
Loading history...
152
        $recipient->write();
153
154
        $this->assertEquals($recipient->SendPlain, 0);
0 ignored issues
show
Bug Best Practice introduced by
The property SendPlain does not exist on SilverStripe\UserForms\M...ecipient\EmailRecipient. Since you implemented __get, consider adding a @property annotation.
Loading history...
155
        $this->assertEquals($recipient->getEmailBodyContent(), $emailBodyHtml);
156
157
        $recipient->SendPlain = 1;
0 ignored issues
show
Bug Best Practice introduced by
The property SendPlain does not exist on SilverStripe\UserForms\M...ecipient\EmailRecipient. Since you implemented __set, consider adding a @property annotation.
Loading history...
158
        $recipient->write();
159
160
        $this->assertEquals($recipient->getEmailBodyContent(), $emailBody);
161
162
        $recipient->delete();
163
    }
164
165
    public function testGetEmailTemplateDropdownValues()
166
    {
167
        $page = $this->objFromFixture(UserDefinedForm::class, 'basic-form-page');
168
        $recipient = new EmailRecipient();
169
        $recipient->FormID = $page->ID;
0 ignored issues
show
Bug Best Practice introduced by
The property FormID does not exist on SilverStripe\UserForms\M...ecipient\EmailRecipient. Since you implemented __set, consider adding a @property annotation.
Loading history...
170
171
        $result = $recipient->getEmailTemplateDropdownValues();
172
173
        // Installation path can be as a project when testing in Travis, so check partial match
174
        $this->assertContains('email/SubmittedFormEmail', key($result));
175
        $this->assertSame('SubmittedFormEmail', current($result));
176
    }
177
178
    public function testEmailTemplateExists()
179
    {
180
        $page = $this->objFromFixture(UserDefinedForm::class, 'basic-form-page');
181
        $recipient = new EmailRecipient();
182
        $recipient->FormID = $page->ID;
0 ignored issues
show
Bug Best Practice introduced by
The property FormID does not exist on SilverStripe\UserForms\M...ecipient\EmailRecipient. Since you implemented __set, consider adding a @property annotation.
Loading history...
183
184
        // Set the default template
185
        $recipient->EmailTemplate = current(array_keys($recipient->getEmailTemplateDropdownValues()));
0 ignored issues
show
Bug Best Practice introduced by
The property EmailTemplate does not exist on SilverStripe\UserForms\M...ecipient\EmailRecipient. Since you implemented __set, consider adding a @property annotation.
Loading history...
186
        $recipient->write();
187
188
        // The default template exists
189
        $this->assertTrue($recipient->emailTemplateExists());
190
191
        // A made up template doesn't exists
192
        $this->assertFalse($recipient->emailTemplateExists('MyTemplateThatsNotThere'));
193
194
        $recipient->delete();
195
    }
196
197
    public function testCanEditAndDeleteRecipient()
198
    {
199
        $form = $this->objFromFixture(UserDefinedForm::class, 'basic-form-page');
200
201
        $this->logInWithPermission('ADMIN');
202
        foreach ($form->EmailRecipients() as $recipient) {
203
            $this->assertTrue($recipient->canEdit());
204
            $this->assertTrue($recipient->canDelete());
205
        }
206
207
        $this->logOut();
208
        $this->logInWithPermission('SITETREE_VIEW_ALL');
209
210
        foreach ($form->EmailRecipients() as $recipient) {
211
            $this->assertFalse($recipient->canEdit());
212
            $this->assertFalse($recipient->canDelete());
213
        }
214
    }
215
216
    public function testPublishing()
217
    {
218
        $this->logInWithPermission('ADMIN');
219
220
        $form = $this->objFromFixture(UserDefinedForm::class, 'basic-form-page');
221
        $form->write();
222
223
        $form->publishRecursive();
224
225
        $live = Versioned::get_one_by_stage(UserDefinedForm::class, 'Live', "\"UserDefinedForm_Live\".\"ID\" = $form->ID");
226
227
        $this->assertNotNull($live);
228
        $this->assertEquals(2, $live->Fields()->Count()); // one page and one field
229
230
        $dropdown = $this->objFromFixture(EditableDropdown::class, 'basic-dropdown');
231
        $form->Fields()->add($dropdown);
232
233
        $stage = Versioned::get_one_by_stage(UserDefinedForm::class, 'Stage', "\"UserDefinedForm\".\"ID\" = $form->ID");
234
        $this->assertEquals(3, $stage->Fields()->Count());
235
236
        // should not have published the dropdown
237
        $liveDropdown = Versioned::get_one_by_stage(EditableFormField::class, 'Live', "\"EditableFormField_Live\".\"ID\" = $dropdown->ID");
238
        $this->assertNull($liveDropdown);
239
240
        // when publishing it should have added it
241
        $form->publishRecursive();
242
243
        $live = Versioned::get_one_by_stage(UserDefinedForm::class, 'Live', "\"UserDefinedForm_Live\".\"ID\" = $form->ID");
244
        $this->assertEquals(3, $live->Fields()->Count());
245
246
        // edit the title
247
        $text = $form->Fields()->limit(1, 1)->First();
248
        $text->Title = 'Edited title';
249
        $text->write();
250
251
        $liveText = Versioned::get_one_by_stage(EditableFormField::class, 'Live', "\"EditableFormField_Live\".\"ID\" = $text->ID");
252
        $this->assertFalse($liveText->Title == $text->Title);
253
254
        $form->publishRecursive();
255
256
        $liveText = Versioned::get_one_by_stage(EditableFormField::class, 'Live', "\"EditableFormField_Live\".\"ID\" = $text->ID");
257
        $this->assertTrue($liveText->Title == $text->Title);
258
259
        // Add a display rule to the dropdown
260
        $displayRule = new EditableCustomRule();
261
        $displayRule->ParentID = $dropdown->ID;
0 ignored issues
show
Bug Best Practice introduced by
The property ParentID does not exist on SilverStripe\UserForms\Model\EditableCustomRule. Since you implemented __set, consider adding a @property annotation.
Loading history...
262
        $displayRule->ConditionFieldID = $text->ID;
0 ignored issues
show
Bug Best Practice introduced by
The property ConditionFieldID does not exist on SilverStripe\UserForms\Model\EditableCustomRule. Since you implemented __set, consider adding a @property annotation.
Loading history...
263
        $displayRule->write();
264
        $ruleID = $displayRule->ID;
265
266
        // Not live
267
        $liveRule = Versioned::get_one_by_stage(EditableCustomRule::class, 'Live', "\"EditableCustomRule_Live\".\"ID\" = $ruleID");
268
        $this->assertEmpty($liveRule);
269
270
        // Publish form, it's now live
271
        $form->publishRecursive();
272
        $liveRule = Versioned::get_one_by_stage(EditableCustomRule::class, 'Live', "\"EditableCustomRule_Live\".\"ID\" = $ruleID");
273
        $this->assertNotEmpty($liveRule);
274
275
        // Remove rule
276
        $displayRule->delete();
277
278
        // Live rule still exists
279
        $liveRule = Versioned::get_one_by_stage(EditableCustomRule::class, 'Live', "\"EditableCustomRule_Live\".\"ID\" = $ruleID");
280
        $this->assertNotEmpty($liveRule);
281
282
        // Publish form, it should remove this rule
283
        /**
284
         * @todo Currently failing, revisit once https://github.com/silverstripe/silverstripe-versioned/issues/34 is resolved
285
         */
286
        // $form->publishRecursive();
0 ignored issues
show
Unused Code Comprehensibility introduced by
72% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
287
        // $liveRule = Versioned::get_one_by_stage(EditableCustomRule::class, 'Live', "\"EditableCustomRule_Live\".\"ID\" = $ruleID");
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
288
        // $this->assertEmpty($liveRule);
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
289
    }
290
291
    public function testUnpublishing()
292
    {
293
        $this->logInWithPermission('ADMIN');
294
        $form = $this->objFromFixture(UserDefinedForm::class, 'basic-form-page');
295
        $form->write();
296
        $this->assertEquals(0, DB::query("SELECT COUNT(*) FROM \"EditableFormField_Live\"")->value());
297
        $form->publishRecursive();
298
299
        // assert that it exists and has a field
300
        $live = Versioned::get_one_by_stage(UserDefinedForm::class, 'Live', "\"UserDefinedForm_Live\".\"ID\" = $form->ID");
301
302
        $this->assertTrue(isset($live));
303
        $this->assertEquals(2, DB::query("SELECT COUNT(*) FROM \"EditableFormField_Live\"")->value());
304
305
        // unpublish
306
        $form->doUnpublish();
307
308
        $this->assertNull(Versioned::get_one_by_stage(UserDefinedForm::class, 'Live', "\"UserDefinedForm_Live\".\"ID\" = $form->ID"));
309
        $this->assertEquals(0, DB::query("SELECT COUNT(*) FROM \"EditableFormField_Live\"")->value());
310
    }
311
312
    public function testDoRevertToLive()
313
    {
314
        $this->logInWithPermission('ADMIN');
315
        $form = $this->objFromFixture(UserDefinedForm::class, 'basic-form-page');
316
        $field = $form->Fields()->First();
317
318
        $field->Title = 'Title';
319
        $field->write();
320
321
        $form->publishRecursive();
322
323
        $field->Title = 'Edited title';
324
        $field->write();
325
326
        // check that the published version is not updated
327
        $live = Versioned::get_one_by_stage(EditableFormField::class, 'Live', "\"EditableFormField_Live\".\"ID\" = $field->ID");
328
        $this->assertInstanceOf(EditableFormField::class, $live);
329
        $this->assertEquals('Title', $live->Title);
330
331
        // revert back to the live data
332
        $form->doRevertToLive();
333
        $form->flushCache();
334
335
        $check = Versioned::get_one_by_stage(EditableFormField::class, 'Stage', "\"EditableFormField\".\"ID\" = $field->ID");
336
337
        $this->assertEquals('Title', $check->Title);
338
    }
339
340
    public function testDuplicatingForm()
341
    {
342
        $this->logInWithPermission('ADMIN');
343
        $form = $this->objFromFixture(UserDefinedForm::class, 'basic-form-page');
344
345
        $duplicate = $form->duplicate();
346
347
        $this->assertEquals($form->Fields()->Count(), $duplicate->Fields()->Count());
348
349
        // can't compare object since the dates/ids change
350
        $this->assertEquals($form->Fields()->First()->Title, $duplicate->Fields()->First()->Title);
351
352
        // Test duplicate with group
353
        $form2 = $this->objFromFixture(UserDefinedForm::class, 'page-with-group');
354
        $form2Validator = new UserFormValidator();
355
        $form2Validator->setForm(new Form(new Controller(), Form::class, new FieldList(), new FieldList()));
356
        $this->assertTrue($form2Validator->php($form2->toMap()));
357
358
        // Check field groups exist
359
        $form2GroupStart = $form2->Fields()->filter('ClassName', EditableFieldGroup::class)->first();
360
        $form2GroupEnd = $form2->Fields()->filter('ClassName', EditableFieldGroupEnd::class)->first();
361
        $this->assertEquals($form2GroupEnd->ID, $form2GroupStart->EndID);
362
363
        // Duplicate this
364
        $form3 = $form2->duplicate();
365
        $form3Validator = new UserFormValidator();
366
        $form3Validator->setForm(new Form(new Controller(), Form::class, new FieldList(), new FieldList()));
367
        $this->assertTrue($form3Validator->php($form3->toMap()));
368
        // Check field groups exist
369
        $form3GroupStart = $form3->Fields()->filter('ClassName', EditableFieldGroup::class)->first();
370
        $form3GroupEnd = $form3->Fields()->filter('ClassName', EditableFieldGroupEnd::class)->first();
371
        $this->assertEquals($form3GroupEnd->ID, $form3GroupStart->EndID);
372
        $this->assertNotEquals($form2GroupEnd->ID, $form3GroupStart->EndID);
373
    }
374
375
    public function testFormOptions()
376
    {
377
        $this->logInWithPermission('ADMIN');
378
        $form = $this->objFromFixture(UserDefinedForm::class, 'basic-form-page');
379
380
        $fields = $form->getFormOptions();
381
        $submit = $fields->fieldByName('SubmitButtonText');
382
        $reset = $fields->fieldByName('ShowClearButton');
383
384
        $this->assertEquals($submit->Title(), 'Text on submit button:');
385
        $this->assertEquals($reset->Title(), 'Show Clear Form Button');
386
    }
387
388
    public function testEmailRecipientFilters()
389
    {
390
        /** @var UserDefinedForm $form */
391
        $form = $this->objFromFixture(UserDefinedForm::class, 'filtered-form-page');
392
393
        // Check unfiltered recipients
394
        $result0 = $form
395
            ->EmailRecipients()
396
            ->sort('EmailAddress')
397
            ->column('EmailAddress');
398
        $this->assertEquals(
399
            [
400
                '[email protected]',
401
                '[email protected]',
402
                '[email protected]'
403
            ],
404
            $result0
405
        );
406
407
        // check filters based on given data
408
        $result1 = $form->FilteredEmailRecipients(
409
            [
410
                'your-name' => 'Value',
411
                'address' => '',
412
                'street' => 'Anything',
413
                'city' => 'Matches Not Equals',
414
                'colours' => ['Red'] // matches 2
415
            ],
416
            null
417
        )
418
            ->sort('EmailAddress')
419
            ->column('EmailAddress');
420
        $this->assertEquals(
421
            [
422
                '[email protected]',
423
                '[email protected]'
424
            ],
425
            $result1
426
        );
427
428
        // Check all positive matches
429
        $result2 = $form->FilteredEmailRecipients(
430
            [
431
                'your-name' => '',
432
                'address' => 'Anything',
433
                'street' => 'Matches Equals',
434
                'city' => 'Anything',
435
                'colours' => ['Red', 'Blue'] // matches 2
436
            ],
437
            null
438
        )
439
            ->sort('EmailAddress')
440
            ->column('EmailAddress');
441
        $this->assertEquals(
442
            [
443
                '[email protected]',
444
                '[email protected]',
445
                '[email protected]'
446
            ],
447
            $result2
448
        );
449
450
        $result3 = $form->FilteredEmailRecipients(
451
            [
452
                'your-name' => 'Should be blank but is not',
453
                'address' => 'Anything',
454
                'street' => 'Matches Equals',
455
                'city' => 'Anything',
456
                'colours' => ['Blue']
457
            ],
458
            null
459
        )->column('EmailAddress');
460
        $this->assertEquals(
461
            [
462
                '[email protected]'
463
            ],
464
            $result3
465
        );
466
467
468
        $result4 = $form->FilteredEmailRecipients(
469
            [
470
                'your-name' => '',
471
                'address' => 'Anything',
472
                'street' => 'Wrong value for this field',
473
                'city' => '',
474
                'colours' => ['Blue', 'Green']
475
            ],
476
            null
477
        )->column('EmailAddress');
478
        $this->assertEquals(
479
            ['[email protected]'],
480
            $result4
481
        );
482
    }
483
484
    public function testIndex()
485
    {
486
        // Test that the $UserDefinedForm is stripped out
487
        $page = $this->objFromFixture(UserDefinedForm::class, 'basic-form-page');
488
        $page->publish('Stage', 'Live');
489
490
        $result = $this->get($page->Link());
491
        $body = Convert::nl2os($result->getBody(), ''); // strip out newlines
492
        $this->assertFalse($result->isError());
493
        $this->assertContains('<p>Here is my form</p><form', $body);
494
        $this->assertContains('</form><p>Thank you for filling it out</p>', $body);
495
496
        $this->assertNotContains('<p>$UserDefinedForm</p>', $body);
497
        $this->assertNotContains('<p></p>', $body);
498
        $this->assertNotContains('</p><p>Thank you for filling it out</p>', $body);
499
    }
500
501
    public function testEmailAddressValidation()
502
    {
503
        $this->logInWithPermission('ADMIN');
504
505
        // test invalid email addresses fail validation
506
        $recipient = $this->objFromFixture(
507
            EmailRecipient::class,
508
            'invalid-recipient-list'
509
        );
510
        $result = $recipient->validate();
511
        $this->assertFalse($result->isValid());
512
        $this->assertNotEmpty($result->getMessages());
513
        $this->assertContains('filtered.example.com', $result->getMessages()[0]['message']);
514
        $this->assertNotContains('[email protected]', $result->getMessages()[0]['message']);
515
516
        // test valid email addresses pass validation
517
        $recipient = $this->objFromFixture(
518
            EmailRecipient::class,
519
            'valid-recipient-list'
520
        );
521
        $result = $recipient->validate();
522
        $this->assertTrue($result->isValid());
523
        $this->assertEmpty($result->getMessages());
524
    }
525
}
526