commit | author | age
|
0fa54d
|
1 |
<?php |
AM |
2 |
|
|
3 |
/** |
|
4 |
* Test class to test rcube_enriched class |
|
5 |
* |
|
6 |
* @package Tests |
|
7 |
*/ |
|
8 |
class Framework_Enriched extends PHPUnit_Framework_TestCase |
|
9 |
{ |
|
10 |
|
|
11 |
/** |
|
12 |
* Class constructor |
|
13 |
*/ |
|
14 |
function test_class() |
|
15 |
{ |
|
16 |
$object = new rcube_enriched(); |
|
17 |
|
|
18 |
$this->assertInstanceOf('rcube_enriched', $object, "Class constructor"); |
|
19 |
} |
|
20 |
|
|
21 |
/** |
|
22 |
* Test to_html() |
|
23 |
*/ |
|
24 |
function test_to_html() |
|
25 |
{ |
|
26 |
$enriched = '<bold><italic>the-text</italic></bold>'; |
|
27 |
$expected = '<b><i>the-text</i></b>'; |
|
28 |
$result = rcube_enriched::to_html($enriched); |
|
29 |
|
|
30 |
$this->assertSame($expected, $result); |
|
31 |
} |
|
32 |
|
|
33 |
/** |
|
34 |
* Data for test_formatting() |
|
35 |
*/ |
|
36 |
function data_formatting() |
|
37 |
{ |
|
38 |
return array( |
|
39 |
array('<bold>', '<b>'), |
|
40 |
array('</bold>', '</b>'), |
|
41 |
array('<italic>', '<i>'), |
|
42 |
array('</italic>', '</i>'), |
|
43 |
array('<fixed>', '<tt>'), |
|
44 |
array('</fixed>', '</tt>'), |
|
45 |
array('<smaller>', '<font size=-1>'), |
|
46 |
array('</smaller>', '</font>'), |
|
47 |
array('<bigger>', '<font size=+1>'), |
|
48 |
array('</bigger>', '</font>'), |
|
49 |
array('<underline>', '<span style="text-decoration: underline">'), |
|
50 |
array('</underline>', '</span>'), |
|
51 |
array('<flushleft>', '<span style="text-align: left">'), |
|
52 |
array('</flushleft>', '</span>'), |
|
53 |
array('<flushright>', '<span style="text-align: right">'), |
|
54 |
array('</flushright>', '</span>'), |
|
55 |
array('<flushboth>', '<span style="text-align: justified">'), |
|
56 |
array('</flushboth>', '</span>'), |
|
57 |
array('<indent>', '<span style="padding-left: 20px">'), |
|
58 |
array('</indent>', '</span>'), |
|
59 |
array('<indentright>', '<span style="padding-right: 20px">'), |
|
60 |
array('</indentright>', '</span>'), |
|
61 |
); |
|
62 |
} |
|
63 |
|
|
64 |
/** |
|
65 |
* Test formatting conversion |
|
66 |
* @dataProvider data_formatting |
|
67 |
*/ |
|
68 |
function test_formatting($enriched, $expected) |
|
69 |
{ |
|
70 |
$result = rcube_enriched::to_html($enriched); |
|
71 |
|
|
72 |
$this->assertSame($expected, $result); |
|
73 |
} |
|
74 |
} |