legacy support with test cases

This commit is contained in:
euromark 2012-08-17 13:57:47 +02:00
parent 40398429ff
commit 7969062614
2 changed files with 23 additions and 3 deletions

View file

@ -459,6 +459,27 @@ podeís adquirirla.</span></p>
$this->assertEquals($expected, $result); $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 * testTail method
* *

View file

@ -480,11 +480,10 @@ class String {
$default = array( $default = array(
'ellipsis' => '...', 'exact' => true, 'html' => false 'ellipsis' => '...', 'exact' => true, 'html' => false
); );
if (!empty($options['html'])) {
$default['ellipsis'] = chr(226);
}
if (isset($options['ending'])) { if (isset($options['ending'])) {
$default['ellipsis'] = $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); $options = array_merge($default, $options);
extract($options); extract($options);