Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding tests for utf8 chars to TextHelper::truncate()

  • Loading branch information...
commit ee7015c9bdbde698f3be79d115dd68fbef63a8c4 1 parent 55ef5ce
@markstory markstory authored
Showing with 26 additions and 24 deletions.
  1. +26 −24 cake/tests/cases/libs/view/helpers/text.test.php
View
50 cake/tests/cases/libs/view/helpers/text.test.php
@@ -74,30 +74,32 @@ function testTruncate() {
$text6 = '<p><strong>Extra dates have been announced for this year\'s tour.</strong></p><p>Tickets for the new shows in</p>';
$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';
-
- $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), '<b>&copy; 2005-20...');
- $this->assertIdentical($this->Text->{$m}($text4, 15), '<img src="my...');
- $this->assertIdentical($this->Text->{$m}($text5, 6, ''), '0<b>1<');
- $this->assertIdentical($this->Text->{$m}($text1, 15, array('ending' => '...', 'exact' => true, 'considerHtml' => true)), 'The quick br...');
- $this->assertIdentical($this->Text->{$m}($text1, 15, '...', true, true), 'The quick br...');
- $this->assertIdentical($this->Text->{$m}($text1, 15, '...', false, true), 'The quick...');
- $this->assertIdentical($this->Text->{$m}($text2, 10, '...', true, true), 'Heiz&ouml;lr...');
- $this->assertIdentical($this->Text->{$m}($text2, 10, '...', false, true), '...');
- $this->assertIdentical($this->Text->{$m}($text3, 20, '...', true, true), '<b>&copy; 2005-2007, Cake...</b>');
- $this->assertIdentical($this->Text->{$m}($text4, 15, '...', true, true), '<img src="mypic.jpg"> This image ...');
- $this->assertIdentical($this->Text->{$m}($text4, 45, '...', true, true), '<img src="mypic.jpg"> This image tag is not XHTML conform!<br><hr/><b>But t...</b>');
- $this->assertIdentical($this->Text->{$m}($text4, 90, '...', true, true), '<img src="mypic.jpg"> This image tag is not XHTML conform!<br><hr/><b>But the following image tag should be conform <img src="mypic.jpg" alt="Me, myself and I" /></b><br />Grea...');
- $this->assertIdentical($this->Text->{$m}($text5, 6, '', true, true), '0<b>1<i>2<span class="myclass">3</span>4<u>5</u></i></b>');
- $this->assertIdentical($this->Text->{$m}($text5, 20, '', true, true), $text5);
- $this->assertIdentical($this->Text->{$m}($text6, 57, '...', false, true), "<p><strong>Extra dates have been announced for this year's...</strong></p>");
- $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...');
+ $text9 = 'НОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь';
+
+ $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), '<b>&copy; 2005-20...');
+ $this->assertIdentical($this->Text->truncate($text4, 15), '<img src="my...');
+ $this->assertIdentical($this->Text->truncate($text5, 6, ''), '0<b>1<');
+ $this->assertIdentical($this->Text->truncate($text1, 15, array('ending' => '...', 'exact' => true, 'considerHtml' => true)), 'The quick br...');
+ $this->assertIdentical($this->Text->truncate($text1, 15, '...', true, true), 'The quick br...');
+ $this->assertIdentical($this->Text->truncate($text1, 15, '...', false, true), 'The quick...');
+ $this->assertIdentical($this->Text->truncate($text2, 10, '...', true, true), 'Heiz&ouml;lr...');
+ $this->assertIdentical($this->Text->truncate($text2, 10, '...', false, true), '...');
+ $this->assertIdentical($this->Text->truncate($text3, 20, '...', true, true), '<b>&copy; 2005-2007, Cake...</b>');
+ $this->assertIdentical($this->Text->truncate($text4, 15, '...', true, true), '<img src="mypic.jpg"> This image ...');
+ $this->assertIdentical($this->Text->truncate($text4, 45, '...', true, true), '<img src="mypic.jpg"> This image tag is not XHTML conform!<br><hr/><b>But t...</b>');
+ $this->assertIdentical($this->Text->truncate($text4, 90, '...', true, true), '<img src="mypic.jpg"> This image tag is not XHTML conform!<br><hr/><b>But the following image tag should be conform <img src="mypic.jpg" alt="Me, myself and I" /></b><br />Grea...');
+ $this->assertIdentical($this->Text->truncate($text5, 6, '', true, true), '0<b>1<i>2<span class="myclass">3</span>4<u>5</u></i></b>');
+ $this->assertIdentical($this->Text->truncate($text5, 20, '', true, true), $text5);
+ $this->assertIdentical($this->Text->truncate($text6, 57, '...', false, true), "<p><strong>Extra dates have been announced for this year's...</strong></p>");
+ $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), 'НОПРСТУ...');
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.