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