File: HtmlTest.php

package info (click to toggle)
php-roundcube-rtf-html-php 2.2-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 276 kB
  • sloc: php: 1,277; makefile: 10
file content (91 lines) | stat: -rw-r--r-- 2,148 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php

use PHPUnit\Framework\TestCase;
use RtfHtmlPhp\Document;
use RtfHtmlPhp\Html\HtmlFormatter;

class HtmlTest extends TestCase
{
    public function testHtml1()
    {
        $rtf = file_get_contents("tests/rtf/html1.rtf");
        $document = new Document($rtf);
        $formatter = new HtmlFormatter();
        $html = $formatter->format($document);

        $this->assertEquals(
            "<html><style>v\\:* {\tcolor:red;}\n</style>"
                . "<span style='font-size:11pt;'>&nbsp;</span>",
            $html
        );
    }

    public function testHtml2()
    {
        $rtf = file_get_contents("tests/rtf/html2.rtf");
        $document = new Document($rtf);
        $formatter = new HtmlFormatter();
        $html = $formatter->format($document);

        $expected = <<<EOT
<HTML><head>
<style>
<!--
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal {font-family:Arial;}
-->
</style>
	<!-- This is a HTML comment.
There is a horizontal tab (%x09) character before the comment, 
and some new lines inside the comment. -->
</head>
<body>
<p
class="MsoNormal">Note the line break inside a P tag. <b>This is a bold text</b> 

</p>
<p class="MsoNormal">
This is a normal text with a character references:&nbsp; &lt; &uml;<br>

characters that have special meaning in RTF: {}\<br>


</p>
<ol>
    <li class="MsoNormal">This is a list item

</ol>
</body>
</HTML>

EOT;

        $this->assertEquals($expected, $html);
  }

    public function testHtml3()
    {
        $rtf = file_get_contents("tests/rtf/html3.rtf");
        $document = new Document($rtf);
        $formatter = new HtmlFormatter('UTF-8');
        $html = $formatter->format($document);

        $expected = <<<EOT
<div dir="ltr">這是一個文本字符串<br>
זהו   מחרוזת  טקסט.<br clear="all"><div><br>

</div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div style="font-size:12.8px">This is your third encoding.... maybe?
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div></div>

EOT;

        $this->assertEquals($expected, $html);
    }
}