‪TYPO3CMS  9.5
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 
17 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
18 
22 class ‪MailMessageTest extends UnitTestCase
23 {
27  protected ‪$subject;
28 
29  protected function ‪setUp()
30  {
31  $this->subject = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\‪TYPO3\CMS\Core\Mail\MailMessage::class);
32  }
33 
38  {
39  return [
40  'string with ascii email address' => [
41  'john.doe@example.com',
42  'john.doe@example.com'
43  ],
44  'string with utf8 email address' => [
45  'john.doe@☺example.com',
46  'john.doe@xn--example-tc7d.com'
47  ]
48  ];
49  }
50 
57  public function ‪setReturnPathIdnaEncodesAddresses($address, $expected)
58  {
59  $this->subject->setReturnPath($address);
60 
61  $this->assertSame($expected, $this->subject->getReturnPath());
62  }
63 
67  public function ‪senderEmailAddressDataProvider()
68  {
69  return [
70  'string with ascii email address' => [
71  'john.doe@example.com',
72  [
73  'john.doe@example.com' => null,
74  ]
75  ],
76  'string with utf8 email address' => [
77  'john.doe@☺example.com',
78  [
79  'john.doe@xn--example-tc7d.com' => null,
80  ]
81  ]
82  ];
83  }
84 
91  public function ‪setSenderIdnaEncodesAddresses($address, $expected)
92  {
93  $this->subject->setSender($address);
94 
95  $this->assertSame($expected, $this->subject->getSender());
96  }
97 
101  public function ‪emailAddressesDataProvider()
102  {
103  return [
104  'string with ascii email address' => [
105  'john.doe@example.com',
106  [
107  'john.doe@example.com' => null
108  ]
109  ],
110  'string with utf8 email address' => [
111  'john.doe@☺example.com',
112  [
113  'john.doe@xn--example-tc7d.com' => null
114  ]
115  ],
116  'array with ascii email addresses' => [
117  [
118  'john.doe@example.com' => 'John Doe',
119  'jane.doe@example.com'
120  ],
121  [
122  'john.doe@example.com' => 'John Doe',
123  'jane.doe@example.com' => null,
124  ],
125  ],
126  'array with utf8 email addresses' => [
127  [
128  'john.doe@☺example.com' => 'John Doe',
129  'jane.doe@äöu.com' => 'Jane Doe',
130  ],
131  [
132  'john.doe@xn--example-tc7d.com' => 'John Doe',
133  'jane.doe@xn--u-zfa8c.com' => 'Jane Doe',
134  ],
135  ],
136  'array with mixed email addresses' => [
137  [
138  'john.doe@☺example.com' => 'John Doe',
139  'jane.doe@example.com' => 'Jane Doe',
140  ],
141  [
142  'john.doe@xn--example-tc7d.com' => 'John Doe',
143  'jane.doe@example.com' => 'Jane Doe',
144  ],
145  ],
146  ];
147  }
148 
155  public function ‪setFromIdnaEncodesAddresses($addresses, $expected)
156  {
157  $this->subject->setFrom($addresses);
158 
159  $this->assertSame($expected, $this->subject->getFrom());
160  }
161 
168  public function ‪setReplyToIdnaEncodesAddresses($addresses, $expected)
169  {
170  $this->subject->setReplyTo($addresses);
171 
172  $this->assertSame($expected, $this->subject->getReplyTo());
173  }
174 
181  public function ‪setToIdnaEncodesAddresses($addresses, $expected)
182  {
183  $this->subject->setTo($addresses);
184 
185  $this->assertSame($expected, $this->subject->getTo());
186  }
187 
194  public function ‪setCcIdnaEncodesAddresses($addresses, $expected)
195  {
196  $this->subject->setCc($addresses);
197 
198  $this->assertSame($expected, $this->subject->getCc());
199  }
200 
207  public function ‪setBccIdnaEncodesAddresses($addresses, $expected)
208  {
209  $this->subject->setBcc($addresses);
210 
211  $this->assertSame($expected, $this->subject->getBcc());
212  }
213 
220  public function ‪setReadReceiptToIdnaEncodesAddresses($addresses, $expected)
221  {
222  $this->subject->setReadReceiptTo($addresses);
223 
224  $this->assertSame($expected, $this->subject->getReadReceiptTo());
225  }
226 }
‪TYPO3\CMS\Core\Tests\Unit\Mail
‪TYPO3
‪TYPO3\CMS\Core\Tests\Unit\Mail\MailMessageTest\setUp
‪setUp()
Definition: MailMessageTest.php:28
‪TYPO3\CMS\Core\Tests\Unit\Mail\MailMessageTest\returnPathEmailAddressDataProvider
‪returnPathEmailAddressDataProvider()
Definition: MailMessageTest.php:36
‪TYPO3\CMS\Core\Tests\Unit\Mail\MailMessageTest\setFromIdnaEncodesAddresses
‪setFromIdnaEncodesAddresses($addresses, $expected)
Definition: MailMessageTest.php:154
‪TYPO3\CMS\Core\Tests\Unit\Mail\MailMessageTest\setSenderIdnaEncodesAddresses
‪setSenderIdnaEncodesAddresses($address, $expected)
Definition: MailMessageTest.php:90
‪TYPO3\CMS\Core\Tests\Unit\Mail\MailMessageTest\setCcIdnaEncodesAddresses
‪setCcIdnaEncodesAddresses($addresses, $expected)
Definition: MailMessageTest.php:193
‪TYPO3\CMS\Core\Tests\Unit\Mail\MailMessageTest\emailAddressesDataProvider
‪emailAddressesDataProvider()
Definition: MailMessageTest.php:100
‪TYPO3\CMS\Core\Tests\Unit\Mail\MailMessageTest\$subject
‪TYPO3 CMS Core Mail MailMessage $subject
Definition: MailMessageTest.php:26
‪TYPO3\CMS\Core\Tests\Unit\Mail\MailMessageTest\setToIdnaEncodesAddresses
‪setToIdnaEncodesAddresses($addresses, $expected)
Definition: MailMessageTest.php:180
‪TYPO3\CMS\Core\Tests\Unit\Mail\MailMessageTest
Definition: MailMessageTest.php:23
‪TYPO3\CMS\Core\Tests\Unit\Mail\MailMessageTest\setReadReceiptToIdnaEncodesAddresses
‪setReadReceiptToIdnaEncodesAddresses($addresses, $expected)
Definition: MailMessageTest.php:219
‪TYPO3\CMS\Core\Tests\Unit\Mail\MailMessageTest\senderEmailAddressDataProvider
‪senderEmailAddressDataProvider()
Definition: MailMessageTest.php:66
‪TYPO3\CMS\Core\Tests\Unit\Mail\MailMessageTest\setReplyToIdnaEncodesAddresses
‪setReplyToIdnaEncodesAddresses($addresses, $expected)
Definition: MailMessageTest.php:167
‪TYPO3\CMS\Core\Tests\Unit\Mail\MailMessageTest\setBccIdnaEncodesAddresses
‪setBccIdnaEncodesAddresses($addresses, $expected)
Definition: MailMessageTest.php:206
‪TYPO3\CMS\Core\Tests\Unit\Mail\MailMessageTest\setReturnPathIdnaEncodesAddresses
‪setReturnPathIdnaEncodesAddresses($address, $expected)
Definition: MailMessageTest.php:56