1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
namespace FH\Bundle\MailerBundle\Tests\Email; |
5
|
|
|
|
6
|
|
|
use FH\Bundle\MailerBundle\Email\MessageOptions; |
7
|
|
|
use FH\Bundle\MailerBundle\Email\Participants; |
8
|
|
|
use PHPUnit\Framework\TestCase; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* @covers \FH\Bundle\MailerBundle\Email\Participants |
12
|
|
|
*/ |
13
|
|
|
final class ParticipantsOptionsTest extends TestCase |
14
|
|
|
{ |
15
|
|
|
private $participants; |
16
|
|
|
|
17
|
|
|
protected function setUp(): void |
18
|
|
|
{ |
19
|
|
|
$this->participants = Participants::fromArray([ |
20
|
|
|
'sender' => [ |
21
|
|
|
'name' => 'Mr. Test', |
22
|
|
|
'address' => '[email protected]', |
23
|
|
|
], |
24
|
|
|
'from' => [ |
25
|
|
|
[ |
26
|
|
|
'name' => 'Mr. Test', |
27
|
|
|
'address' => '[email protected]', |
28
|
|
|
], |
29
|
|
|
], |
30
|
|
|
'reply_to' => [ |
31
|
|
|
[ |
32
|
|
|
'name' => 'Mr. Test', |
33
|
|
|
'address' => '[email protected]', |
34
|
|
|
], |
35
|
|
|
], |
36
|
|
|
'to' => [ |
37
|
|
|
[ |
38
|
|
|
'name' => 'Ms. Test', |
39
|
|
|
'address' => '[email protected]', |
40
|
|
|
], |
41
|
|
|
[ |
42
|
|
|
'name' => 'Test Junior', |
43
|
|
|
'address' => '[email protected]', |
44
|
|
|
], |
45
|
|
|
], |
46
|
|
|
'cc' => [ |
47
|
|
|
[ |
48
|
|
|
'name' => 'Ms. Test', |
49
|
|
|
'address' => '[email protected]', |
50
|
|
|
], |
51
|
|
|
], |
52
|
|
|
'bcc' => [ |
53
|
|
|
[ |
54
|
|
|
'name' => 'Ms. Test', |
55
|
|
|
'address' => '[email protected]', |
56
|
|
|
], |
57
|
|
|
], |
58
|
|
|
]); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function testFromArray(): void |
62
|
|
|
{ |
63
|
|
|
// Sender |
64
|
|
|
$this->assertTrue($this->participants->hasSender()); |
65
|
|
|
$this->assertSame('Mr. Test', $this->participants->getSender()->getName()); |
66
|
|
|
$this->assertSame('[email protected]', $this->participants->getSender()->getAddress()); |
67
|
|
|
|
68
|
|
|
// From |
69
|
|
|
$this->assertTrue($this->participants->hasFrom()); |
70
|
|
|
$this->assertCount(1, $this->participants->getFrom()); |
71
|
|
|
$this->assertSame('Mr. Test', $this->participants->getFrom()[0]->getName()); |
72
|
|
|
$this->assertSame('[email protected]', $this->participants->getFrom()[0]->getAddress()); |
73
|
|
|
|
74
|
|
|
// Reply to |
75
|
|
|
$this->assertTrue($this->participants->hasReplyTo()); |
76
|
|
|
$this->assertCount(1, $this->participants->getReplyTo()); |
77
|
|
|
$this->assertSame('Mr. Test', $this->participants->getReplyTo()[0]->getName()); |
78
|
|
|
$this->assertSame('[email protected]', $this->participants->getReplyTo()[0]->getAddress()); |
79
|
|
|
|
80
|
|
|
// To |
81
|
|
|
$this->assertTrue($this->participants->hasTo()); |
82
|
|
|
$this->assertCount(2, $this->participants->getTo()); |
83
|
|
|
$this->assertSame('Ms. Test', $this->participants->getTo()[0]->getName()); |
84
|
|
|
$this->assertSame('[email protected]', $this->participants->getFrom()[0]->getAddress()); |
85
|
|
|
$this->assertSame('Test Junior', $this->participants->getTo()[1]->getName()); |
86
|
|
|
$this->assertSame('[email protected]', $this->participants->getTo()[1]->getAddress()); |
87
|
|
|
|
88
|
|
|
// Cc |
89
|
|
|
$this->assertTrue($this->participants->hasCc()); |
90
|
|
|
$this->assertCount(1, $this->participants->getCc()); |
91
|
|
|
$this->assertSame('Ms. Test', $this->participants->getCc()[0]->getName()); |
92
|
|
|
$this->assertSame('[email protected]', $this->participants->getCc()[0]->getAddress()); |
93
|
|
|
|
94
|
|
|
// Bcc |
95
|
|
|
$this->assertTrue($this->participants->hasBcc()); |
96
|
|
|
$this->assertCount(1, $this->participants->getBcc()); |
97
|
|
|
$this->assertSame('Ms. Test', $this->participants->getBcc()[0]->getName()); |
98
|
|
|
$this->assertSame('[email protected]', $this->participants->getBcc()[0]->getAddress()); |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|