From ee7015c9bdbde698f3be79d115dd68fbef63a8c4 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 7 Oct 2009 23:56:38 -0400 Subject: [PATCH] Adding tests for utf8 chars to TextHelper::truncate() --- .../cases/libs/view/helpers/text.test.php | 48 ++++++++++--------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/cake/tests/cases/libs/view/helpers/text.test.php b/cake/tests/cases/libs/view/helpers/text.test.php index 43c6a048f..748754073 100644 --- a/cake/tests/cases/libs/view/helpers/text.test.php +++ b/cake/tests/cases/libs/view/helpers/text.test.php @@ -74,30 +74,32 @@ class TextHelperTest extends CakeTestCase { $text6 = '

Extra dates have been announced for this year\'s tour.

Tickets for the new shows in

'; $text7 = 'El moño está en el lugar correcto. Eso fue lo que dijo la niña, ¿habrá dicho la verdad?'; $text8 = 'Vive la R'.chr(195).chr(169).'publique de France'; + $text9 = 'НОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; - $this->assertIdentical($this->Text->{$m}($text1, 15), 'The quick br...'); - $this->assertIdentical($this->Text->{$m}($text1, 15, '...', false), 'The quick...'); - $this->assertIdentical($this->Text->{$m}($text1, 100), 'The quick brown fox jumps over the lazy dog'); - $this->assertIdentical($this->Text->{$m}($text2, 10, '...'), 'Heiz&ou...'); - $this->assertIdentical($this->Text->{$m}($text2, 10, '...', false), '...'); - $this->assertIdentical($this->Text->{$m}($text3, 20), '© 2005-20...'); - $this->assertIdentical($this->Text->{$m}($text4, 15), ' This image ...'); - $this->assertIdentical($this->Text->{$m}($text4, 45, '...', true, true), ' This image tag is not XHTML conform!

But t...'); - $this->assertIdentical($this->Text->{$m}($text4, 90, '...', true, true), ' This image tag is not XHTML conform!

But the following image tag should be conform Me, myself and I
Grea...'); - $this->assertIdentical($this->Text->{$m}($text5, 6, '', true, true), '012345'); - $this->assertIdentical($this->Text->{$m}($text5, 20, '', true, true), $text5); - $this->assertIdentical($this->Text->{$m}($text6, 57, '...', false, true), "

Extra dates have been announced for this year's...

"); - $this->assertIdentical($this->Text->{$m}($text7, 255), $text7); - $this->assertIdentical($this->Text->{$m}($text7, 15), 'El moño está...'); - $this->assertIdentical($this->Text->{$m}($text8, 15), 'Vive la R'.chr(195).chr(169).'pu...'); + $this->assertIdentical($this->Text->truncate($text1, 15), 'The quick br...'); + $this->assertIdentical($this->Text->truncate($text1, 15, '...', false), 'The quick...'); + $this->assertIdentical($this->Text->truncate($text1, 100), 'The quick brown fox jumps over the lazy dog'); + $this->assertIdentical($this->Text->truncate($text2, 10, '...'), 'Heiz&ou...'); + $this->assertIdentical($this->Text->truncate($text2, 10, '...', false), '...'); + $this->assertIdentical($this->Text->truncate($text3, 20), '© 2005-20...'); + $this->assertIdentical($this->Text->truncate($text4, 15), ' This image ...'); + $this->assertIdentical($this->Text->truncate($text4, 45, '...', true, true), ' This image tag is not XHTML conform!

But t...'); + $this->assertIdentical($this->Text->truncate($text4, 90, '...', true, true), ' This image tag is not XHTML conform!

But the following image tag should be conform Me, myself and I
Grea...'); + $this->assertIdentical($this->Text->truncate($text5, 6, '', true, true), '012345'); + $this->assertIdentical($this->Text->truncate($text5, 20, '', true, true), $text5); + $this->assertIdentical($this->Text->truncate($text6, 57, '...', false, true), "

Extra dates have been announced for this year's...

"); + $this->assertIdentical($this->Text->truncate($text7, 255), $text7); + $this->assertIdentical($this->Text->truncate($text7, 15), 'El moño está...'); + $this->assertIdentical($this->Text->truncate($text8, 15), 'Vive la R'.chr(195).chr(169).'pu...'); + $this->assertIdentical($this->Text->truncate($text9, 10), 'НОПРСТУ...'); } /**