Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
justinfreeman (Agileware)
Core
Commits
c25cbd3a
Commit
c25cbd3a
authored
11 years ago
by
Kurund Jalmi
Browse files
Options
Downloads
Plain Diff
Merge pull request #963 from dlobo/CRM-12766
CRM-12766 - Unit test for html2text
parents
7a251c9b
7a999eae
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CRM/Utils/String.php
+2
-2
2 additions, 2 deletions
CRM/Utils/String.php
tests/phpunit/CRM/Utils/HtmlToTextTest.php
+46
-0
46 additions, 0 deletions
tests/phpunit/CRM/Utils/HtmlToTextTest.php
with
48 additions
and
2 deletions
CRM/Utils/String.php
+
2
−
2
View file @
c25cbd3a
...
...
@@ -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
();
}
...
...
This diff is collapsed.
Click to expand it.
tests/phpunit/CRM/Utils/HtmlToTextTest.php
0 → 100644
+
46
−
0
View file @
c25cbd3a
<?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
"
);
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment