Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

legacy support with test cases

  • Loading branch information...
commit 79690626141b9ccb7fd05f4440b76f133e4869a8 1 parent 4039842
@dereuromark dereuromark authored
View
21 lib/Cake/Test/Case/Utility/StringTest.php
@@ -460,6 +460,27 @@ public function testTruncate() {
}
/**
+ * 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
*
* @return void
View
5 lib/Cake/Utility/String.php
@@ -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);
Please sign in to comment.
Something went wrong with that request. Please try again.