commit | author | age
|
eda92e
|
1 |
<?php |
AM |
2 |
|
|
3 |
/** |
|
4 |
* Test class to test rcube_text2html class |
|
5 |
* |
|
6 |
* @package Tests |
|
7 |
*/ |
|
8 |
class Framework_Text2Html extends PHPUnit_Framework_TestCase |
|
9 |
{ |
|
10 |
|
|
11 |
/** |
|
12 |
* Data for test_text2html() |
|
13 |
*/ |
|
14 |
function data_text2html() |
|
15 |
{ |
|
16 |
$options = array( |
|
17 |
'begin' => '', |
|
18 |
'end' => '', |
|
19 |
'break' => '<br>', |
|
20 |
'links' => false, |
|
21 |
'flowed' => false, |
f09924
|
22 |
'wrap' => false, |
eda92e
|
23 |
'space' => '_', // replace UTF-8 non-breaking space for simpler testing |
c4ad7e
|
24 |
'nobr_start' => '>', |
AM |
25 |
'nobr_end' => '<', |
eda92e
|
26 |
); |
AM |
27 |
|
c4ad7e
|
28 |
$data[] = array(" aaaa", ">_aaaa<", $options); |
AM |
29 |
$data[] = array("aa>aa", ">aa>aa<", $options); |
|
30 |
$data[] = array("aaaa aaaa", ">aaaa_aaaa<", $options); |
|
31 |
$data[] = array("aaaa aaaa", ">aaaa__aaaa<", $options); |
|
32 |
$data[] = array("aaaa aaaa", ">aaaa___aaaa<", $options); |
|
33 |
$data[] = array("aaaa\taaaa", ">aaaa____aaaa<", $options); |
eda92e
|
34 |
$data[] = array("aaaa\naaaa", "aaaa<br>aaaa", $options); |
c4ad7e
|
35 |
$data[] = array("aaaa\n aaaa", "aaaa<br>>_aaaa<", $options); |
AM |
36 |
$data[] = array("aaaa\n aaaa", "aaaa<br>>__aaaa<", $options); |
|
37 |
$data[] = array("aaaa\n aaaa", "aaaa<br>>___aaaa<", $options); |
|
38 |
$data[] = array("\n", "<br>", $options); |
|
39 |
$data[] = array("\taaaa", ">____aaaa<", $options); |
eda92e
|
40 |
$data[] = array("\naaaa", "<br>aaaa", $options); |
c4ad7e
|
41 |
$data[] = array("\n aaaa", "<br>>_aaaa<", $options); |
AM |
42 |
$data[] = array("\n aaaa", "<br>>__aaaa<", $options); |
|
43 |
$data[] = array("\n aaaa", "<br>>___aaaa<", $options); |
eda92e
|
44 |
$data[] = array("aaaa\n\nbbbb", "aaaa<br><br>bbbb", $options); |
c4ad7e
|
45 |
$data[] = array(">aaaa \n>aaaa", "<blockquote>>aaaa_<<br>aaaa</blockquote>", $options); |
eda92e
|
46 |
$data[] = array(">aaaa\n>aaaa", "<blockquote>aaaa<br>aaaa</blockquote>", $options); |
c4ad7e
|
47 |
$data[] = array(">aaaa \n>bbbb\ncccc dddd", "<blockquote>>aaaa_<<br>bbbb</blockquote>>cccc_dddd<", $options); |
AM |
48 |
$data[] = array("aaaa-bbbb/cccc", ">aaaa-bbbb/cccc<", $options); |
afd090
|
49 |
$data[] = array("aaaa-bbbb\r\tcccc", ">aaaa-bbbb____cccc<", $options); |
eda92e
|
50 |
|
AM |
51 |
$options['flowed'] = true; |
|
52 |
|
|
53 |
$data[] = array(" aaaa", "aaaa", $options); |
c4ad7e
|
54 |
$data[] = array("aaaa aaaa", ">aaaa_aaaa<", $options); |
AM |
55 |
$data[] = array("aaaa aaaa", ">aaaa__aaaa<", $options); |
|
56 |
$data[] = array("aaaa aaaa", ">aaaa___aaaa<", $options); |
|
57 |
$data[] = array("aaaa\taaaa", ">aaaa____aaaa<", $options); |
eda92e
|
58 |
$data[] = array("aaaa\naaaa", "aaaa<br>aaaa", $options); |
AM |
59 |
$data[] = array("aaaa\n aaaa", "aaaa<br>aaaa", $options); |
c4ad7e
|
60 |
$data[] = array("aaaa\n aaaa", "aaaa<br>>_aaaa<", $options); |
AM |
61 |
$data[] = array("aaaa\n aaaa", "aaaa<br>>__aaaa<", $options); |
|
62 |
$data[] = array("\taaaa", ">____aaaa<", $options); |
eda92e
|
63 |
$data[] = array("\naaaa", "<br>aaaa", $options); |
AM |
64 |
$data[] = array("\n aaaa", "<br>aaaa", $options); |
c4ad7e
|
65 |
$data[] = array("\n aaaa", "<br>>_aaaa<", $options); |
AM |
66 |
$data[] = array("\n aaaa", "<br>>__aaaa<", $options); |
eda92e
|
67 |
$data[] = array("aaaa\n\nbbbb", "aaaa<br><br>bbbb", $options); |
AM |
68 |
$data[] = array(">aaaa \n>aaaa", "<blockquote>aaaa aaaa</blockquote>", $options); |
|
69 |
$data[] = array(">aaaa\n>aaaa", "<blockquote>aaaa<br>aaaa</blockquote>", $options); |
c4ad7e
|
70 |
$data[] = array(">aaaa \n>bbbb\ncccc dddd", "<blockquote>aaaa bbbb</blockquote>>cccc_dddd<", $options); |
AM |
71 |
$data[] = array("\x02\x03", ">\x02\x03<", $options); |
eda92e
|
72 |
|
c0a5aa
|
73 |
$options['flowed'] = false; |
AM |
74 |
$options['wrap'] = true; |
|
75 |
|
|
76 |
$data[] = array(">>aaaa bbbb\n>>\n>>>\n>cccc\n\ndddd eeee", |
|
77 |
"<blockquote><blockquote>aaaa bbbb<br><br><blockquote><br></blockquote></blockquote>cccc</blockquote><br>dddd eeee", $options); |
|
78 |
$data[] = array("\n>>aaaa\n\ndddd", |
|
79 |
"<br><blockquote><blockquote>aaaa</blockquote></blockquote><br>dddd", $options); |
|
80 |
$data[] = array("aaaa\n>bbbb\n>cccc\n\ndddd\n>>test", |
|
81 |
"aaaa<blockquote>bbbb<br>cccc</blockquote><br>dddd<blockquote><blockquote>test</blockquote></blockquote>", $options); |
|
82 |
|
eda92e
|
83 |
return $data; |
AM |
84 |
} |
|
85 |
|
|
86 |
/** |
|
87 |
* Test text to html conversion |
|
88 |
* |
|
89 |
* @dataProvider data_text2html |
|
90 |
*/ |
|
91 |
function test_text2html($input, $output, $options) |
|
92 |
{ |
|
93 |
$t2h = new rcube_text2html($input, false, $options); |
|
94 |
|
|
95 |
$html = $t2h->get_html(); |
|
96 |
|
|
97 |
$this->assertEquals($output, $html); |
|
98 |
} |
|
99 |
} |