Commit | Line | Data |
---|---|---|
7a999eae DL |
1 | <?php |
2 | ||
3 | require_once 'CiviTest/CiviUnitTestCase.php'; | |
4 | ||
aba1cd8b EM |
5 | /** |
6 | * Class CRM_Utils_HtmlToTextTest | |
7 | */ | |
7a999eae DL |
8 | class CRM_Utils_HtmlToTextTest extends CiviUnitTestCase { |
9 | protected $_testInput = array( | |
10 | '<br><p>' => '', // empty test | |
11 | ' | |
12 | <p> | |
13 | This is a paragraph with <b>Bold</b> and <i>italics</i> | |
14 | Also some <a href="http://www.example.com">hrefs</a> and a | |
15 | few <mailto:"info@example.org">mailto</mailto> tags. | |
16 | This is also a really long long line' => ' | |
17 | This is a paragraph with BOLD and _italics_ Also some hrefs [1] and a few | |
18 | mailto tags. This is also a really long long line | |
19 | ||
20 | Links: | |
21 | ------ | |
22 | [1] http://www.example.com | |
e1330b8a KW |
23 | ', |
24 | ' | |
25 | <p> | |
26 | A <a href="{action.do_something}">token</a> | |
27 | is not treated as a relative URL' => ' | |
28 | A token [1] is not treated as a relative URL | |
29 | ||
30 | Links: | |
31 | ------ | |
32 | [1] {action.do_something} | |
33 | ', | |
7a999eae DL |
34 | ); |
35 | ||
4cbe18b8 EM |
36 | /** |
37 | * @return array | |
38 | */ | |
7a999eae DL |
39 | function get_info() { |
40 | return array( | |
41 | 'name' => 'HtmlToText Test', | |
42 | 'description' => 'Test htmlToText Function', | |
43 | 'group' => 'CiviCRM BAO Tests', | |
44 | ); | |
45 | } | |
46 | ||
47 | function setUp() { | |
48 | parent::setUp(); | |
49 | } | |
50 | ||
51 | function testHtmlToText() { | |
52 | foreach ($this->_testInput as $html => $text) { | |
53 | $output = CRM_Utils_String::htmlToText($html); | |
54 | $this->assertEquals( | |
55 | trim($output), | |
56 | trim($text), | |
57 | "Text Output did not match for $html" | |
58 | ); | |
59 | } | |
60 | } | |
61 | } | |
62 |