commit | author | age
|
13326b
|
1 |
<?php |
A |
2 |
|
|
3 |
/** |
|
4 |
* Test class to test messages decoding functions |
|
5 |
* |
|
6 |
* @package Tests |
|
7 |
*/ |
|
8 |
class rcube_test_maildecode extends UnitTestCase |
|
9 |
{ |
|
10 |
private $app; |
|
11 |
|
|
12 |
function __construct() |
|
13 |
{ |
|
14 |
$this->UnitTestCase('Mail headers decoding tests'); |
|
15 |
|
|
16 |
$this->app = rcmail::get_instance(); |
|
17 |
$this->app->imap_init(false); |
|
18 |
} |
|
19 |
|
|
20 |
/** |
|
21 |
* Test decoding of single e-mail address strings |
|
22 |
* Uses rcube_imap::decode_address_list() |
|
23 |
*/ |
|
24 |
function test_decode_single_address() |
|
25 |
{ |
|
26 |
$headers = array( |
|
27 |
0 => 'test@domain.tld', |
|
28 |
1 => '<test@domain.tld>', |
|
29 |
2 => 'Test <test@domain.tld>', |
|
30 |
3 => 'Test Test <test@domain.tld>', |
|
31 |
4 => 'Test Test<test@domain.tld>', |
|
32 |
5 => '"Test Test" <test@domain.tld>', |
|
33 |
6 => '"Test Test"<test@domain.tld>', |
|
34 |
7 => '"Test \\" Test" <test@domain.tld>', |
|
35 |
8 => '"Test<Test" <test@domain.tld>', |
|
36 |
9 => '=?ISO-8859-1?B?VGVzdAo=?= <test@domain.tld>', |
|
37 |
10 => '=?ISO-8859-1?B?VGVzdAo=?=<test@domain.tld>', // #1487068 |
6c68cb
|
38 |
// comments in address (#1487673) |
A |
39 |
11 => 'Test (comment) <test@domain.tld>', |
|
40 |
12 => '"Test" (comment) <test@domain.tld>', |
|
41 |
13 => '"Test (comment)" (comment) <test@domain.tld>', |
|
42 |
14 => '(comment) <test@domain.tld>', |
|
43 |
15 => 'Test <test@(comment)domain.tld>', |
|
44 |
16 => 'Test Test ((comment)) <test@domain.tld>', |
|
45 |
17 => 'test@domain.tld (comment)', |
|
46 |
18 => '"Test,Test" <test@domain.tld>', |
13326b
|
47 |
); |
A |
48 |
|
|
49 |
$results = array( |
6c68cb
|
50 |
0 => array(1, '', 'test@domain.tld'), |
A |
51 |
1 => array(1, '', 'test@domain.tld'), |
|
52 |
2 => array(1, 'Test', 'test@domain.tld'), |
|
53 |
3 => array(1, 'Test Test', 'test@domain.tld'), |
|
54 |
4 => array(1, 'Test Test', 'test@domain.tld'), |
|
55 |
5 => array(1, 'Test Test', 'test@domain.tld'), |
|
56 |
6 => array(1, 'Test Test', 'test@domain.tld'), |
|
57 |
7 => array(1, 'Test " Test', 'test@domain.tld'), |
|
58 |
8 => array(1, 'Test<Test', 'test@domain.tld'), |
|
59 |
9 => array(1, 'Test', 'test@domain.tld'), |
|
60 |
10 => array(1, 'Test', 'test@domain.tld'), |
|
61 |
11 => array(1, 'Test', 'test@domain.tld'), |
|
62 |
12 => array(1, 'Test', 'test@domain.tld'), |
|
63 |
13 => array(1, 'Test (comment)', 'test@domain.tld'), |
|
64 |
14 => array(1, '', 'test@domain.tld'), |
|
65 |
15 => array(1, 'Test', 'test@domain.tld'), |
|
66 |
16 => array(1, 'Test Test', 'test@domain.tld'), |
|
67 |
17 => array(1, '', 'test@domain.tld'), |
|
68 |
18 => array(1, 'Test,Test', 'test@domain.tld'), |
13326b
|
69 |
); |
A |
70 |
|
|
71 |
foreach ($headers as $idx => $header) { |
|
72 |
$res = $this->app->imap->decode_address_list($header); |
|
73 |
|
6c68cb
|
74 |
$this->assertEqual($results[$idx][0], count($res), "Rows number in result for header: " . $header); |
A |
75 |
$this->assertEqual($results[$idx][1], $res[1]['name'], "Name part decoding for header: " . $header); |
|
76 |
$this->assertEqual($results[$idx][2], $res[1]['mailto'], "Name part decoding for header: " . $header); |
13326b
|
77 |
} |
A |
78 |
} |
|
79 |
|
|
80 |
} |