Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | require_once 'CiviTest/CiviUnitTestCase.php'; | |
3 | class CRM_Utils_MailTest extends CiviUnitTestCase { | |
4 | function get_info() { | |
5 | return array( | |
6 | 'name' => 'Mail Test', | |
7 | 'description' => 'Test RFC822 formatting', | |
8 | 'group' => 'CiviCRM BAO Tests', | |
9 | ); | |
10 | } | |
11 | ||
12 | function setUp() { | |
13 | parent::setUp(); | |
14 | } | |
15 | ||
16 | /** | |
17 | * test case for add( ) | |
18 | * test with empty params. | |
19 | */ | |
20 | function testFormatRFC822() { | |
21 | ||
22 | $values = array( | |
23 | array('name' => "Test User", | |
24 | 'email' => "foo@bar.com", | |
25 | 'result' => "Test User <foo@bar.com>", | |
26 | ), | |
27 | array( | |
28 | 'name' => '"Test User"', | |
29 | 'email' => "foo@bar.com", | |
30 | 'result' => "Test User <foo@bar.com>", | |
31 | ), | |
32 | array( | |
33 | 'name' => "User, Test", | |
34 | 'email' => "foo@bar.com", | |
35 | 'result' => '"User, Test" <foo@bar.com>', | |
36 | ), | |
37 | array( | |
38 | 'name' => '"User, Test"', | |
39 | 'email' => "foo@bar.com", | |
40 | 'result' => '"User, Test" <foo@bar.com>', | |
41 | ), | |
42 | array( | |
43 | 'name' => '"Test User"', | |
44 | 'email' => "foo@bar.com", | |
45 | 'result' => '"Test User" <foo@bar.com>', | |
46 | 'useQuote' => TRUE, | |
47 | ), | |
48 | array( | |
49 | 'name' => "User, Test", | |
50 | 'email' => "foo@bar.com", | |
51 | 'result' => '"User, Test" <foo@bar.com>', | |
52 | 'useQuote' => TRUE, | |
53 | ), | |
54 | ); | |
55 | foreach ($values as $value) { | |
56 | $result = CRM_Utils_Mail::formatRFC822Email($value['name'], | |
57 | $value['email'], | |
58 | CRM_Utils_Array::value('useQuote', $value, FALSE) | |
59 | ); | |
60 | $this->assertEquals($result, $value['result'], 'Expected encoding does not match'); | |
61 | } | |
62 | } | |
63 | } | |
64 |