Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
aba1cd8b EM |
2 | |
3 | /** | |
4 | * Class CRM_Utils_MailTest | |
acb109b7 | 5 | * @group headless |
aba1cd8b | 6 | */ |
6a488035 | 7 | class CRM_Utils_MailTest extends CiviUnitTestCase { |
6a488035 | 8 | |
00be9182 | 9 | public function setUp() { |
6a488035 TO |
10 | parent::setUp(); |
11 | } | |
12 | ||
13 | /** | |
100fef9d | 14 | * Test case for add( ) |
6a488035 TO |
15 | * test with empty params. |
16 | */ | |
00be9182 | 17 | public function testFormatRFC822() { |
6a488035 TO |
18 | |
19 | $values = array( | |
6c6e6187 | 20 | array( |
92915c55 | 21 | 'name' => "Test User", |
6a488035 TO |
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 | } | |
96025800 | 61 | |
6a488035 | 62 | } |