tests - add autogenerated comment blocks
[civicrm-core.git] / tests / phpunit / CRM / Utils / HtmlToTextTest.php
CommitLineData
7a999eae
DL
1<?php
2
3require_once 'CiviTest/CiviUnitTestCase.php';
4
aba1cd8b
EM
5/**
6 * Class CRM_Utils_HtmlToTextTest
7 */
7a999eae
DL
8class CRM_Utils_HtmlToTextTest extends CiviUnitTestCase {
9 protected $_testInput = array(
10 '<br><p>' => '', // empty test
11 '
12<p>
13This is a paragraph with <b>Bold</b> and <i>italics</i>
14Also some <a href="http://www.example.com">hrefs</a> and a
15few <mailto:"info@example.org">mailto</mailto> tags.
16This is also a really long long line' => '
17This is a paragraph with BOLD and _italics_ Also some hrefs [1] and a few
18mailto tags. This is also a really long long line
19
20Links:
21------
22[1] http://www.example.com
e1330b8a
KW
23',
24 '
25<p>
26A <a href="{action.do_something}">token</a>
27is not treated as a relative URL' => '
28A token [1] is not treated as a relative URL
29
30Links:
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