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