From 7a999eae768a9a8904a26a174d82a0298cb3d659 Mon Sep 17 00:00:00 2001 From: "Donald A. Lobo" Date: Wed, 5 Jun 2013 08:50:04 -0700 Subject: [PATCH] CRM-12766 ---------------------------------------- * CRM-12766: Upgrade html2text to version shipped by roundcube http://issues.civicrm.org/jira/browse/CRM-12766 --- CRM/Utils/String.php | 4 +- tests/phpunit/CRM/Utils/HtmlToTextTest.php | 46 ++++++++++++++++++++++ 2 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 tests/phpunit/CRM/Utils/HtmlToTextTest.php diff --git a/CRM/Utils/String.php b/CRM/Utils/String.php index 9289125691..05fd8fd59e 100644 --- a/CRM/Utils/String.php +++ b/CRM/Utils/String.php @@ -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(); } diff --git a/tests/phpunit/CRM/Utils/HtmlToTextTest.php b/tests/phpunit/CRM/Utils/HtmlToTextTest.php new file mode 100644 index 0000000000..ecce076452 --- /dev/null +++ b/tests/phpunit/CRM/Utils/HtmlToTextTest.php @@ -0,0 +1,46 @@ +

' => '', // empty test + ' +

+This is a paragraph with Bold and italics +Also some hrefs and a +few 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" + ); + } + } +} + -- 2.25.1