1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2023 |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
namespace Aimeos\Base\Mail\Message; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
class SymfonyTest extends \PHPUnit\Framework\TestCase |
13
|
|
|
{ |
14
|
|
|
private $object; |
15
|
|
|
private $mailer; |
16
|
|
|
private $mock; |
17
|
|
|
|
18
|
|
|
|
19
|
|
|
protected function setUp() : void |
20
|
|
|
{ |
21
|
|
|
if( !class_exists( 'Symfony\Component\Mime\Email' ) ) { |
22
|
|
|
$this->markTestSkipped( 'Class Symfony\Component\Mime\Email not found' ); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
$this->mailer = $this->getMockBuilder( 'Symfony\Component\Mailer\MailerInterface' ) |
26
|
|
|
->disableOriginalConstructor() |
27
|
|
|
->getMock(); |
28
|
|
|
|
29
|
|
|
$this->mock = $this->getMockBuilder( 'Symfony\Component\Mime\Email' ) |
30
|
|
|
->disableOriginalConstructor() |
31
|
|
|
->getMock(); |
32
|
|
|
|
33
|
|
|
$this->object = new \Aimeos\Base\Mail\Message\Symfony( $this->mailer, $this->mock, 'UTF-8' ); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
|
37
|
|
|
protected function tearDown() : void |
38
|
|
|
{ |
39
|
|
|
unset( $this->object, $this->mock ); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
|
43
|
|
|
public function testFrom() |
44
|
|
|
{ |
45
|
|
|
$this->mock->expects( $this->once() )->method( 'from' ); |
46
|
|
|
|
47
|
|
|
$result = $this->object->from( 'a@b', 'test' ); |
48
|
|
|
$this->assertSame( $this->object, $result ); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
|
52
|
|
|
public function testTo() |
53
|
|
|
{ |
54
|
|
|
$this->mock->expects( $this->once() )->method( 'to' ); |
55
|
|
|
|
56
|
|
|
$result = $this->object->to( 'a@b', 'test' ); |
57
|
|
|
$this->assertSame( $this->object, $result ); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
|
61
|
|
|
public function testCc() |
62
|
|
|
{ |
63
|
|
|
$this->mock->expects( $this->once() )->method( 'cc' ); |
64
|
|
|
|
65
|
|
|
$result = $this->object->cc( 'a@b', 'test' ); |
66
|
|
|
$this->assertSame( $this->object, $result ); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
|
70
|
|
|
public function testBcc() |
71
|
|
|
{ |
72
|
|
|
$this->mock->expects( $this->once() )->method( 'bcc' ); |
73
|
|
|
|
74
|
|
|
$result = $this->object->bcc( 'a@b', 'test' ); |
75
|
|
|
$this->assertSame( $this->object, $result ); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
|
79
|
|
|
public function testReplyTo() |
80
|
|
|
{ |
81
|
|
|
$this->mock->expects( $this->once() )->method( 'replyTo' ); |
82
|
|
|
|
83
|
|
|
$result = $this->object->replyTo( 'a@b', 'test' ); |
84
|
|
|
$this->assertSame( $this->object, $result ); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
|
88
|
|
|
public function testSend() |
89
|
|
|
{ |
90
|
|
|
$this->mailer->expects( $this->once() )->method( 'send' ); |
91
|
|
|
$this->assertSame( $this->object, $this->object->send() ); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
|
95
|
|
|
public function testSender() |
96
|
|
|
{ |
97
|
|
|
$this->mock->expects( $this->once() )->method( 'sender' ); |
98
|
|
|
|
99
|
|
|
$result = $this->object->sender( 'a@b', 'test' ); |
100
|
|
|
$this->assertSame( $this->object, $result ); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
|
104
|
|
|
public function testSubject() |
105
|
|
|
{ |
106
|
|
|
$this->mock->expects( $this->once() )->method( 'subject' ) |
107
|
|
|
->with( $this->stringContains( 'test' ) ); |
108
|
|
|
|
109
|
|
|
$result = $this->object->subject( 'test' ); |
110
|
|
|
$this->assertSame( $this->object, $result ); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
|
114
|
|
|
public function testText() |
115
|
|
|
{ |
116
|
|
|
$this->mock->expects( $this->once() )->method( 'text' ) |
117
|
|
|
->with( $this->stringContains( 'test' ) ); |
118
|
|
|
|
119
|
|
|
$result = $this->object->text( 'test' ); |
120
|
|
|
$this->assertSame( $this->object, $result ); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
|
124
|
|
|
public function testHtml() |
125
|
|
|
{ |
126
|
|
|
$this->mock->expects( $this->once() )->method( 'html' ) |
127
|
|
|
->with( $this->stringContains( 'test' ) ); |
128
|
|
|
|
129
|
|
|
$result = $this->object->html( 'test' ); |
130
|
|
|
$this->assertSame( $this->object, $result ); |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
|
134
|
|
|
public function testAttach() |
135
|
|
|
{ |
136
|
|
|
$this->mock->expects( $this->once() )->method( 'attach' ); |
137
|
|
|
|
138
|
|
|
$result = $this->object->attach( 'test', 'test.txt', 'text/plain' ); |
139
|
|
|
$this->assertSame( $this->object, $result ); |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
|
143
|
|
|
public function testEmbed() |
144
|
|
|
{ |
145
|
|
|
$this->mock->expects( $this->once() )->method( 'embed' ); |
146
|
|
|
|
147
|
|
|
$result = $this->object->embed( 'test', 'test.txt', 'text/plain' ); |
148
|
|
|
$this->assertEquals( 'cid:test.txt', $result ); |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
|
152
|
|
|
public function testObject() |
153
|
|
|
{ |
154
|
|
|
$this->assertInstanceOf( 'Symfony\Component\Mime\Email', $this->object->object() ); |
155
|
|
|
} |
156
|
|
|
} |
157
|
|
|
|