Mercurial > hg > cmmr2012-drupal-site
comparison core/tests/Drupal/Tests/Component/Utility/MailTest.php @ 4:a9cd425dd02b
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:11:55 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
3:307d7a7fd348 | 4:a9cd425dd02b |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\Tests\Component\Utility; | |
4 | |
5 use Drupal\Component\Utility\Mail; | |
6 use PHPUnit\Framework\TestCase; | |
7 | |
8 /** | |
9 * Test mail helpers implemented in Mail component. | |
10 * | |
11 * @group Utility | |
12 * | |
13 * @coversDefaultClass \Drupal\Component\Utility\Mail | |
14 */ | |
15 class MailTest extends TestCase { | |
16 | |
17 /** | |
18 * Tests RFC-2822 'display-name' formatter. | |
19 * | |
20 * @dataProvider providerTestDisplayName | |
21 * @covers ::formatDisplayName | |
22 */ | |
23 public function testFormatDisplayName($string, $safe_display_name) { | |
24 $this->assertEquals($safe_display_name, Mail::formatDisplayName($string)); | |
25 } | |
26 | |
27 /** | |
28 * Data provider for testFormatDisplayName(). | |
29 * | |
30 * @see testFormatDisplayName() | |
31 * | |
32 * @return array | |
33 * An array containing a string and its 'display-name' safe value. | |
34 */ | |
35 public function providerTestDisplayName() { | |
36 return [ | |
37 // Simple ASCII characters. | |
38 ['Test site', 'Test site'], | |
39 // ASCII with html entity. | |
40 ['Test & site', 'Test & site'], | |
41 // Non-ASCII characters. | |
42 ['Tést site', '=?UTF-8?B?VMOpc3Qgc2l0ZQ==?='], | |
43 // Non-ASCII with special characters. | |
44 ['Tést; site', '=?UTF-8?B?VMOpc3Q7IHNpdGU=?='], | |
45 // Non-ASCII with html entity. | |
46 ['Tést; site', '=?UTF-8?B?VMOpc3Q7IHNpdGU=?='], | |
47 // ASCII with special characters. | |
48 ['Test; site', '"Test; site"'], | |
49 // ASCII with special characters as html entity. | |
50 ['Test < site', '"Test < site"'], | |
51 // ASCII with special characters and '\'. | |
52 ['Test; \ "site"', '"Test; \\\\ \"site\""'], | |
53 // String already RFC-2822 compliant. | |
54 ['"Test; site"', '"Test; site"'], | |
55 // String already RFC-2822 compliant. | |
56 ['"Test; \\\\ \"site\""', '"Test; \\\\ \"site\""'], | |
57 ]; | |
58 } | |
59 | |
60 } |