Added more tests to wrap. Fixed to not cut words with more than should limit.

This commit is contained in:
Juan Basso 2011-03-04 09:48:51 -03:00
parent 985743dc50
commit f661e37ef1
2 changed files with 21 additions and 1 deletions

View file

@ -889,7 +889,7 @@ class CakeEmail {
$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;
}

View file

@ -509,6 +509,26 @@ class CakeEmailTest extends CakeTestCase {
''
);
$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);
}
}