TYPO3 CMS  TYPO3_8-7
MailMessageTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
20 class MailMessageTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
21 {
25  protected $subject;
26 
27  protected function setUp()
28  {
29  $this->subject = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Mail\MailMessage::class);
30  }
31 
36  {
37  return [
38  'string with ascii email address' => [
39  'john.doe@example.com',
40  'john.doe@example.com'
41  ],
42  'string with utf8 email address' => [
43  'john.doe@☺example.com',
44  'john.doe@xn--example-tc7d.com'
45  ]
46  ];
47  }
48 
55  public function setReturnPathIdnaEncodesAddresses($address, $expected)
56  {
57  $this->subject->setReturnPath($address);
58 
59  $this->assertSame($expected, $this->subject->getReturnPath());
60  }
61 
66  {
67  return [
68  'string with ascii email address' => [
69  'john.doe@example.com',
70  [
71  'john.doe@example.com' => null,
72  ]
73  ],
74  'string with utf8 email address' => [
75  'john.doe@☺example.com',
76  [
77  'john.doe@xn--example-tc7d.com' => null,
78  ]
79  ]
80  ];
81  }
82 
89  public function setSenderIdnaEncodesAddresses($address, $expected)
90  {
91  $this->subject->setSender($address);
92 
93  $this->assertSame($expected, $this->subject->getSender());
94  }
95 
99  public function emailAddressesDataProvider()
100  {
101  return [
102  'string with ascii email address' => [
103  'john.doe@example.com',
104  [
105  'john.doe@example.com' => null
106  ]
107  ],
108  'string with utf8 email address' => [
109  'john.doe@☺example.com',
110  [
111  'john.doe@xn--example-tc7d.com' => null
112  ]
113  ],
114  'array with ascii email addresses' => [
115  [
116  'john.doe@example.com' => 'John Doe',
117  'jane.doe@example.com'
118  ],
119  [
120  'john.doe@example.com' => 'John Doe',
121  'jane.doe@example.com' => null,
122  ],
123  ],
124  'array with utf8 email addresses' => [
125  [
126  'john.doe@☺example.com' => 'John Doe',
127  'jane.doe@äöu.com' => 'Jane Doe',
128  ],
129  [
130  'john.doe@xn--example-tc7d.com' => 'John Doe',
131  'jane.doe@xn--u-zfa8c.com' => 'Jane Doe',
132  ],
133  ],
134  'array with mixed email addresses' => [
135  [
136  'john.doe@☺example.com' => 'John Doe',
137  'jane.doe@example.com' => 'Jane Doe',
138  ],
139  [
140  'john.doe@xn--example-tc7d.com' => 'John Doe',
141  'jane.doe@example.com' => 'Jane Doe',
142  ],
143  ],
144  ];
145  }
146 
153  public function setFromIdnaEncodesAddresses($addresses, $expected)
154  {
155  $this->subject->setFrom($addresses);
156 
157  $this->assertSame($expected, $this->subject->getFrom());
158  }
159 
166  public function setReplyToIdnaEncodesAddresses($addresses, $expected)
167  {
168  $this->subject->setReplyTo($addresses);
169 
170  $this->assertSame($expected, $this->subject->getReplyTo());
171  }
172 
179  public function setToIdnaEncodesAddresses($addresses, $expected)
180  {
181  $this->subject->setTo($addresses);
182 
183  $this->assertSame($expected, $this->subject->getTo());
184  }
185 
192  public function setCcIdnaEncodesAddresses($addresses, $expected)
193  {
194  $this->subject->setCc($addresses);
195 
196  $this->assertSame($expected, $this->subject->getCc());
197  }
198 
205  public function setBccIdnaEncodesAddresses($addresses, $expected)
206  {
207  $this->subject->setBcc($addresses);
208 
209  $this->assertSame($expected, $this->subject->getBcc());
210  }
211 
218  public function setReadReceiptToIdnaEncodesAddresses($addresses, $expected)
219  {
220  $this->subject->setReadReceiptTo($addresses);
221 
222  $this->assertSame($expected, $this->subject->getReadReceiptTo());
223  }
224 }
static makeInstance($className,... $constructorArguments)
setReadReceiptToIdnaEncodesAddresses($addresses, $expected)