Skip to content

Commit

Permalink
remove default parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Smeeckaert committed Nov 2, 2015
1 parent ed8569b commit d5df1e4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
22 changes: 11 additions & 11 deletions spec/Coduo/PHPHumanizer/StringSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,20 @@ function it_truncate_string_to_word_closest_to_a_certain_number_of_characters_wi
$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>';

// Test with allowed tags
$this->truncateHtml($text, 3)->shouldReturn("<b>HyperText</b>");
$this->truncateHtml($text, 12)->shouldReturn("<b>HyperText Markup</b>");
$this->truncateHtml($text, 30)->shouldReturn("<b>HyperText Markup Language</b>, commonly");
$this->truncateHtml($text, 50)->shouldReturn("<b>HyperText Markup Language</b>, commonly referred to as");
$this->truncateHtml($text, 75)->shouldReturn('<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>');
$this->truncateHtml($text, 100)->shouldReturn('<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');
$this->truncateHtml($text, 3, '<b><i><u><em><strong><a><span>')->shouldReturn("<b>HyperText</b>");
$this->truncateHtml($text, 12, '<b><i><u><em><strong><a><span>')->shouldReturn("<b>HyperText Markup</b>");
$this->truncateHtml($text, 30, '<b><i><u><em><strong><a><span>')->shouldReturn("<b>HyperText Markup Language</b>, commonly");
$this->truncateHtml($text, 50, '<b><i><u><em><strong><a><span>')->shouldReturn("<b>HyperText Markup Language</b>, commonly referred to as");
$this->truncateHtml($text, 75, '<b><i><u><em><strong><a><span>')->shouldReturn('<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>');
$this->truncateHtml($text, 100, '<b><i><u><em><strong><a><span>')->shouldReturn('<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');

// Test without tags

$this->truncateHtml($text, 3, '')->shouldReturn("HyperText");
$this->truncateHtml($text, 12, '')->shouldReturn("HyperText Markup");
$this->truncateHtml($text, 50, '')->shouldReturn("HyperText Markup Language, commonly referred to as");
$this->truncateHtml($text, 75, '')->shouldReturn('HyperText Markup Language, commonly referred to as HTML, is the standard markup');
$this->truncateHtml($text, 100, '')->shouldReturn('HyperText Markup Language, commonly referred to as HTML, is the standard markup language used to create');
$this->truncateHtml($text, 3)->shouldReturn("HyperText");
$this->truncateHtml($text, 12)->shouldReturn("HyperText Markup");
$this->truncateHtml($text, 50)->shouldReturn("HyperText Markup Language, commonly referred to as");
$this->truncateHtml($text, 75)->shouldReturn('HyperText Markup Language, commonly referred to as HTML, is the standard markup');
$this->truncateHtml($text, 100)->shouldReturn('HyperText Markup Language, commonly referred to as HTML, is the standard markup language used to create');

// Test with append
$this->truncateHtml($text, 50, '', '...')->shouldReturn("HyperText Markup Language, commonly referred to as...");
Expand Down
2 changes: 1 addition & 1 deletion src/Coduo/PHPHumanizer/String.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static function truncate($text, $charactersCount, $append = '')
* @param string $append
* @return string
*/
public static function truncateHtml($text, $charactersCount, $allowedTags = '<b><i><u><em><strong><a><span>', $append = '')
public static function truncateHtml($text, $charactersCount, $allowedTags = '', $append = '')
{
$truncate = new HtmlTruncate(new WordBreakpoint(), $allowedTags, $append);

Expand Down
2 changes: 1 addition & 1 deletion src/Coduo/PHPHumanizer/String/HtmlTruncate.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class HtmlTruncate implements TruncateInterface
* @param string $allowedTags
* @param string $append
*/
public function __construct(Breakpoint $breakpoint, $allowedTags = '<b><i><u><em><strong><a><span>', $append = '')
public function __construct(Breakpoint $breakpoint, $allowedTags = '', $append = '')
{
$this->breakpoint = $breakpoint;
$this->append = $append;
Expand Down

0 comments on commit d5df1e4

Please sign in to comment.