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