Skip to content
Snippets Groups Projects
Commit c25cbd3a authored by Kurund Jalmi's avatar Kurund Jalmi
Browse files

Merge pull request #963 from dlobo/CRM-12766

CRM-12766 - Unit test for html2text
parents 7a251c9b 7a999eae
No related branches found
No related tags found
No related merge requests found
......@@ -409,8 +409,8 @@ class CRM_Utils_String {
* @static
*/
static function htmlToText($html) {
require_once 'packages/html2text/class.html2text.inc';
$converter = new html2text($html);
require_once 'packages/html2text/rcube_html2text.php';
$converter = new rcube_html2text($html);
return $converter->get_text();
}
......
<?php
require_once 'CiviTest/CiviUnitTestCase.php';
class CRM_Utils_HtmlToTextTest extends CiviUnitTestCase {
protected $_testInput = array(
'<br><p>' => '', // empty test
'
<p>
This is a paragraph with <b>Bold</b> and <i>italics</i>
Also some <a href="http://www.example.com">hrefs</a> and a
few <mailto:"info@example.org">mailto</mailto> tags.
This is also a really long long line' => '
This is a paragraph with BOLD and _italics_ Also some hrefs [1] and a few
mailto tags. This is also a really long long line
Links:
------
[1] http://www.example.com
'
);
function get_info() {
return array(
'name' => 'HtmlToText Test',
'description' => 'Test htmlToText Function',
'group' => 'CiviCRM BAO Tests',
);
}
function setUp() {
parent::setUp();
}
function testHtmlToText() {
foreach ($this->_testInput as $html => $text) {
$output = CRM_Utils_String::htmlToText($html);
$this->assertEquals(
trim($output),
trim($text),
"Text Output did not match for $html"
);
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment