1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Metaways Infosystems GmbH, 2013 |
6
|
|
|
* @copyright Aimeos (aimeos.org), 2014-2020 |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
|
10
|
|
|
namespace Aimeos\MW\Mail\Message; |
11
|
|
|
|
12
|
|
|
|
13
|
|
|
require_once dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'MailMessage'; |
14
|
|
|
require_once __DIR__ . DIRECTORY_SEPARATOR . 'TestHeaderSet.php'; |
15
|
|
|
|
16
|
|
|
|
17
|
|
|
class Typo3Test extends \PHPUnit\Framework\TestCase |
18
|
|
|
{ |
19
|
|
|
private $object; |
20
|
|
|
private $mock; |
21
|
|
|
|
22
|
|
|
|
23
|
|
|
protected function setUp() : void |
24
|
|
|
{ |
25
|
|
|
$this->mock = $this->getMockBuilder( 'TYPO3\\CMS\\Core\\Mail\\MailMessage' )->getMock(); |
26
|
|
|
$this->object = new \Aimeos\MW\Mail\Message\Typo3( $this->mock, 'UTF-8' ); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
|
30
|
|
|
protected function tearDown() : void |
31
|
|
|
{ |
32
|
|
|
unset( $this->object, $this->mock ); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
|
36
|
|
|
public function testAddFrom() |
37
|
|
|
{ |
38
|
|
|
$this->mock->expects( $this->once() )->method( 'addFrom' ) |
39
|
|
|
->with( $this->stringContains( 'a@b' ), $this->stringContains( 'test' ) ); |
40
|
|
|
|
41
|
|
|
$result = $this->object->addFrom( 'a@b', 'test' ); |
42
|
|
|
$this->assertSame( $this->object, $result ); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
|
46
|
|
|
public function testAddTo() |
47
|
|
|
{ |
48
|
|
|
$this->mock->expects( $this->once() )->method( 'addTo' ) |
49
|
|
|
->with( $this->stringContains( 'a@b' ), $this->stringContains( 'test' ) ); |
50
|
|
|
|
51
|
|
|
$result = $this->object->addTo( 'a@b', 'test' ); |
52
|
|
|
$this->assertSame( $this->object, $result ); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
|
56
|
|
|
public function testAddCc() |
57
|
|
|
{ |
58
|
|
|
$this->mock->expects( $this->once() )->method( 'addCc' ) |
59
|
|
|
->with( $this->stringContains( 'a@b' ), $this->stringContains( 'test' ) ); |
60
|
|
|
|
61
|
|
|
$result = $this->object->addCc( 'a@b', 'test' ); |
62
|
|
|
$this->assertSame( $this->object, $result ); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
|
66
|
|
|
public function testAddBcc() |
67
|
|
|
{ |
68
|
|
|
$this->mock->expects( $this->once() )->method( 'addBcc' ) |
69
|
|
|
->with( $this->stringContains( 'a@b' ), $this->stringContains( 'test' ) ); |
70
|
|
|
|
71
|
|
|
$result = $this->object->addBcc( 'a@b', 'test' ); |
72
|
|
|
$this->assertSame( $this->object, $result ); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
|
76
|
|
|
public function testAddReplyTo() |
77
|
|
|
{ |
78
|
|
|
$this->mock->expects( $this->once() )->method( 'addReplyTo' ) |
79
|
|
|
->with( $this->stringContains( 'a@b' ), $this->stringContains( 'test' ) ); |
80
|
|
|
|
81
|
|
|
$result = $this->object->addReplyTo( 'a@b', 'test' ); |
82
|
|
|
$this->assertSame( $this->object, $result ); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
|
86
|
|
|
public function testAddHeader() |
87
|
|
|
{ |
88
|
|
|
$headersMock = $this->getMockBuilder( 'Aimeos\MW\Mail\Message\TestHeaderSet' )->getMock(); |
89
|
|
|
|
90
|
|
|
$this->mock->expects( $this->once() )->method( 'getHeaders' ) |
91
|
|
|
->will( $this->returnValue( $headersMock ) ); |
92
|
|
|
|
93
|
|
|
$headersMock->expects( $this->once() )->method( 'addTextHeader' ) |
94
|
|
|
->with( $this->stringContains( 'test' ), $this->stringContains( 'value' ) ); |
95
|
|
|
|
96
|
|
|
$result = $this->object->addHeader( 'test', 'value' ); |
97
|
|
|
$this->assertSame( $this->object, $result ); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
|
101
|
|
|
public function testSend() |
102
|
|
|
{ |
103
|
|
|
$this->mock->expects( $this->once() )->method( 'send' ); |
104
|
|
|
$this->assertSame( $this->object, $this->object->send() ); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
|
108
|
|
|
public function testSetSender() |
109
|
|
|
{ |
110
|
|
|
$this->mock->expects( $this->once() )->method( 'setSender' ) |
111
|
|
|
->with( $this->stringContains( 'a@b' ), $this->stringContains( 'test' ) ); |
112
|
|
|
|
113
|
|
|
$result = $this->object->setSender( 'a@b', 'test' ); |
114
|
|
|
$this->assertSame( $this->object, $result ); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
|
118
|
|
|
public function testSetSubject() |
119
|
|
|
{ |
120
|
|
|
$this->mock->expects( $this->once() )->method( 'setSubject' ) |
121
|
|
|
->with( $this->stringContains( 'test' ) ); |
122
|
|
|
|
123
|
|
|
$result = $this->object->setSubject( 'test' ); |
124
|
|
|
$this->assertSame( $this->object, $result ); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
|
128
|
|
|
public function testSetBody() |
129
|
|
|
{ |
130
|
|
|
$this->mock->expects( $this->once() )->method( 'setBody' ) |
131
|
|
|
->with( $this->stringContains( 'test' ) ); |
132
|
|
|
|
133
|
|
|
$result = $this->object->setBody( 'test' ); |
134
|
|
|
$this->assertSame( $this->object, $result ); |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
|
138
|
|
|
public function testSetBodyHtml() |
139
|
|
|
{ |
140
|
|
|
$this->mock->expects( $this->once() )->method( 'addPart' ) |
141
|
|
|
->with( $this->stringContains( 'test' ) ); |
142
|
|
|
|
143
|
|
|
$result = $this->object->setBodyHtml( 'test' ); |
144
|
|
|
$this->assertSame( $this->object, $result ); |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
|
148
|
|
|
public function testAddAttachment() |
149
|
|
|
{ |
150
|
|
|
$this->markTestIncomplete( 'Swift_Attachment::newInstance() is not testable' ); |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
|
154
|
|
|
public function testEmbedAttachment() |
155
|
|
|
{ |
156
|
|
|
$this->markTestIncomplete( 'Swift_EmbeddedFile::newInstance() is not testable' ); |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
|
160
|
|
|
public function testGetObject() |
161
|
|
|
{ |
162
|
|
|
$this->assertInstanceOf( 'TYPO3\\CMS\\Core\\Mail\\MailMessage', $this->object->getObject() ); |
163
|
|
|
} |
164
|
|
|
} |
165
|
|
|
|