Skip to content
Permalink
Browse files

legacy support with test cases

  • Loading branch information...
dereuromark committed Aug 17, 2012
1 parent 4039842 commit 79690626141b9ccb7fd05f4440b76f133e4869a8
Showing with 23 additions and 3 deletions.
  1. +21 −0 lib/Cake/Test/Case/Utility/StringTest.php
  2. +2 −3 lib/Cake/Utility/String.php
@@ -459,6 +459,27 @@ public function testTruncate() {
$this->assertEquals($expected, $result);
}
/**
* testTruncate method with non utf8 sites
*
* @return void
*/
public function testTruncateLegacy() {
Configure::write('App.encoding', 'ISO-8859-1');
$text = '<b>&copy; 2005-2007, Cake Software Foundation, Inc.</b><br />written by Alexander Wegener';
$result = $this->Text->truncate($text, 31, array(
'exact' => false,
));
$expected = '<b>&copy; 2005-2007, Cake...';
$this->assertEquals($expected, $result);
$result = $this->Text->truncate($text, 31, array(
'exact' => true,
));
$expected = '<b>&copy; 2005-2007, Cake So...';
$this->assertEquals($expected, $result);
}
/**
* testTail method
*
@@ -480,11 +480,10 @@ public static function truncate($text, $length = 100, $options = array()) {
$default = array(
'ellipsis' => '...', 'exact' => true, 'html' => false
);
if (!empty($options['html'])) {
$default['ellipsis'] = chr(226);
}
if (isset($options['ending'])) {
$default['ellipsis'] = $options['ending'];
} elseif (!empty($options['html']) && Configure::read('App.encoding') == 'UTF-8') {
$default['ellipsis'] = chr(226);
}
$options = array_merge($default, $options);
extract($options);

0 comments on commit 7969062

Please sign in to comment.
You can’t perform that action at this time.