Merge pull request #11956 from MiyaNoctem/CRM-50-sub-tabs-for-contributions
[civicrm-core.git] / tests / phpunit / CRM / Utils / MailTest.php
1 <?php
2
3 /**
4 * Class CRM_Utils_MailTest
5 * @group headless
6 */
7 class CRM_Utils_MailTest extends CiviUnitTestCase {
8
9 public function setUp() {
10 parent::setUp();
11 }
12
13 /**
14 * Test case for add( )
15 * test with empty params.
16 */
17 public function testFormatRFC822() {
18
19 $values = array(
20 array(
21 'name' => "Test User",
22 'email' => "foo@bar.com",
23 'result' => "Test User <foo@bar.com>",
24 ),
25 array(
26 'name' => '"Test User"',
27 'email' => "foo@bar.com",
28 'result' => "Test User <foo@bar.com>",
29 ),
30 array(
31 'name' => "User, Test",
32 'email' => "foo@bar.com",
33 'result' => '"User, Test" <foo@bar.com>',
34 ),
35 array(
36 'name' => '"User, Test"',
37 'email' => "foo@bar.com",
38 'result' => '"User, Test" <foo@bar.com>',
39 ),
40 array(
41 'name' => '"Test User"',
42 'email' => "foo@bar.com",
43 'result' => '"Test User" <foo@bar.com>',
44 'useQuote' => TRUE,
45 ),
46 array(
47 'name' => "User, Test",
48 'email' => "foo@bar.com",
49 'result' => '"User, Test" <foo@bar.com>',
50 'useQuote' => TRUE,
51 ),
52 );
53 foreach ($values as $value) {
54 $result = CRM_Utils_Mail::formatRFC822Email($value['name'],
55 $value['email'],
56 CRM_Utils_Array::value('useQuote', $value, FALSE)
57 );
58 $this->assertEquals($result, $value['result'], 'Expected encoding does not match');
59 }
60 }
61
62 }