Skip to content

Commit

Permalink
fix StringTest
Browse files Browse the repository at this point in the history
  • Loading branch information
liuxuhui committed Nov 8, 2015
1 parent 9d17321 commit 73e99d0
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions tests/Coduo/PHPHumanizer/Tests/StringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,16 @@ function test_truncate_string_to_word_closest_to_a_certain_number_of_characters(
$this->assertEquals($expected, String::truncate($text, $charactersCount, $append));
}

function it_truncate_string_to_word_closest_to_a_certain_number_of_characters_with_html_tags($text, $charactersCount, $allowedTags, $expected, $append = '')
/**
* @dataProvider truncateHtmlStringProvider
*
* @param $text
* @param $charactersCount
* @param $allowedTags
* @param $expected
* @param $append
*/
function test_truncate_string_to_word_closest_to_a_certain_number_of_characters_with_html_tags($text, $charactersCount, $allowedTags, $expected, $append = '')
{
$this->assertEquals($expected, String::truncateHtml($text, $charactersCount, $allowedTags, $append));
}
Expand All @@ -57,6 +66,7 @@ public function humanizeStringProvider()
}

/**
*
* @return array
*/
public function truncateStringProvider()
Expand Down Expand Up @@ -84,6 +94,10 @@ public function truncateStringProvider()
);
}

/**
*
* @return array
*/
public function truncateHtmlStringProvider()
{
$text = '<p><b>HyperText Markup Language</b>, commonly referred to as <b>HTML</b>, is the standard <a href="/wiki/Markup_language" title="Markup language">markup language</a> used to create <a href="/wiki/Web_page" title="Web page">web pages</a>.<sup id="cite_ref-1" class="reference"><a href="#cite_note-1"><span>[</span>1<span>]</span></a></sup> <a href="/wiki/Web_browser" title="Web browser">Web browsers</a> can read HTML files and render them into visible or audible web pages. HTML describes the structure of a <a href="/wiki/Website" title="Website">website</a> <a href="/wiki/Semantic" title="Semantic" class="mw-redirect">semantically</a> along with cues for presentation, making it a markup language, rather than a <a href="/wiki/Programming_language" title="Programming language">programming language</a>.</p>';
Expand All @@ -104,4 +118,4 @@ public function truncateHtmlStringProvider()
array($text, 75, '<b><i><u><em><strong><a><span>', '<b>HyperText Markup Language</b>, commonly referred to as <b>HTML</b>, is the standard <a href="/wiki/Markup_language" title="Markup language">markup...</a>', '...')
);
}
}
}

0 comments on commit 73e99d0

Please sign in to comment.