commit | author | age
|
6084d7
|
1 |
<?php |
A |
2 |
|
|
3 |
/** |
|
4 |
* Test class to test html2text class |
|
5 |
* |
|
6 |
* @package Tests |
|
7 |
*/ |
|
8 |
class rcube_test_html2text extends UnitTestCase |
|
9 |
{ |
|
10 |
|
|
11 |
function __construct() |
|
12 |
{ |
|
13 |
$this->UnitTestCase("HTML-to-Text conversion tests"); |
|
14 |
|
|
15 |
} |
|
16 |
|
|
17 |
function test_html2text() |
|
18 |
{ |
|
19 |
$data = array( |
|
20 |
0 => array( |
|
21 |
'title' => 'Test entry', |
|
22 |
'in' => '', |
|
23 |
'out' => '', |
|
24 |
), |
|
25 |
1 => array( |
|
26 |
'title' => 'Basic HTML entities', |
|
27 |
'in' => '"&', |
|
28 |
'out' => '"&', |
|
29 |
), |
|
30 |
2 => array( |
|
31 |
'title' => 'HTML entity string', |
|
32 |
'in' => '&quot;', |
|
33 |
'out' => '"', |
|
34 |
), |
b138a9
|
35 |
3 => array( |
A |
36 |
'title' => 'HTML entity in STRONG tag', |
|
37 |
'in' => '<strong>ś</strong>', // ś |
|
38 |
'out' => 'Ś', // upper ś |
|
39 |
), |
|
40 |
4 => array( |
|
41 |
'title' => 'STRONG tag to upper-case conversion', |
|
42 |
'in' => '<strong>ś</strong>', |
|
43 |
'out' => 'Ś', |
|
44 |
), |
63f23f
|
45 |
5 => array( |
A |
46 |
'title' => 'STRONG inside B tag', |
|
47 |
'in' => '<b><strong>ś</strong></b>', |
|
48 |
'out' => 'Ś', |
|
49 |
), |
6084d7
|
50 |
); |
A |
51 |
|
|
52 |
$ht = new html2text(null, false, false); |
|
53 |
|
63f23f
|
54 |
foreach ($data as $idx => $item) { |
6084d7
|
55 |
$ht->set_html($item['in']); |
A |
56 |
$res = $ht->get_text(); |
63f23f
|
57 |
$this->assertEqual($item['out'], $res, $item['title'] . "($idx)"); |
6084d7
|
58 |
} |
A |
59 |
} |
|
60 |
|
|
61 |
} |