Skip to content

Commit

Permalink
Added more tests to wrap. Fixed to not cut words with more than shoul…
Browse files Browse the repository at this point in the history
…d limit.
  • Loading branch information
jrbasso committed Apr 13, 2011
1 parent 985743d commit f661e37
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Cake/Network/CakeEmail.php
Expand Up @@ -889,7 +889,7 @@ function _wrap($message) {
$line = '.' . $line;
}
if (!preg_match('/\<[a-z]/i', $line)) {
$formatted = array_merge($formatted, explode("\n", wordwrap($line, self::LINE_LENGTH_SHOULD, "\n", true)));
$formatted = array_merge($formatted, explode("\n", wordwrap($line, self::LINE_LENGTH_SHOULD, "\n")));
continue;
}

Expand Down
20 changes: 20 additions & 0 deletions lib/Cake/tests/Case/Network/CakeEmailTest.php
Expand Up @@ -509,6 +509,26 @@ public function testWrap() {
''
);
$this->assertIdentical($result, $expected);

$text = 'Lorem ipsum <a href="http://www.cakephp.org/controller/action/param1/param2" class="nice cool fine amazing awesome">ok</a>';
$result = $this->CakeEmail->wrap($text);
$expected = array(
'Lorem ipsum',
'<a href="http://www.cakephp.org/controller/action/param1/param2" class="nice cool fine amazing awesome">',
'ok</a>',
''
);
$this->assertIdentical($result, $expected);

$text = 'Lorem ipsum withonewordverybigMorethanthelineshouldsizeofrfcspecificationbyieeeavailableonieeesite ok.';
$result = $this->CakeEmail->wrap($text);
$expected = array(
'Lorem ipsum',
'withonewordverybigMorethanthelineshouldsizeofrfcspecificationbyieeeavailableonieeesite',
'ok.',
''
);
$this->assertIdentical($result, $expected);
}

}

0 comments on commit f661e37

Please sign in to comment.