@@ -60,7 +60,7 @@ public function testTruncate() {
60
60
$ text5 = '0<b>1<i>2<span class="myclass">3</span>4<u>5</u>6</i>7</b>8<b>9</b>0 ' ;
61
61
$ text6 = '<p><strong>Extra dates have been announced for this year \'s tour.</strong></p><p>Tickets for the new shows in</p> ' ;
62
62
$ text7 = 'El moño está en el lugar correcto. Eso fue lo que dijo la niña, ¿habrá dicho la verdad? ' ;
63
- $ text8 = 'Vive la R ' . chr (195 ). chr (169 ). 'publique de France ' ;
63
+ $ text8 = 'Vive la R ' . chr (195 ) . chr (169 ) . 'publique de France ' ;
64
64
$ text9 = 'НОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь ' ;
65
65
66
66
$ this ->assertSame ($ this ->Text ->truncate ($ text1 , 15 ), 'The quick br... ' );
@@ -86,6 +86,51 @@ public function testTruncate() {
86
86
$ this ->assertSame ($ this ->Text ->truncate ($ text7 , 15 ), 'El moño está... ' );
87
87
$ this ->assertSame ($ this ->Text ->truncate ($ text8 , 15 ), 'Vive la R ' .chr (195 ).chr (169 ).'pu... ' );
88
88
$ this ->assertSame ($ this ->Text ->truncate ($ text9 , 10 ), 'НОПРСТУ... ' );
89
+
90
+ $ text = '<p><span style="font-size: medium;"><a>Iamatestwithnospacesandhtml</a></span></p> ' ;
91
+ $ result = $ this ->Text ->truncate ($ text , 10 , array (
92
+ 'ending ' => '... ' ,
93
+ 'exact ' => false ,
94
+ 'html ' => true
95
+ ));
96
+ $ expected = '<p><span style="font-size: medium;"><a>...</a></span></p> ' ;
97
+ $ this ->assertEquals ($ expected , $ result );
98
+
99
+ $ text = '<p><span style="font-size: medium;">El biógrafo de Steve Jobs, Walter
100
+ Isaacson, explica porqué Jobs le pidió que le hiciera su biografía en
101
+ este artículo de El País.</span></p>
102
+ <p><span style="font-size: medium;"><span style="font-size:
103
+ large;">Por qué Steve era distinto.</span></span></p>
104
+ <p><span style="font-size: medium;"><a href="http://www.elpais.com/
105
+ articulo/primer/plano/Steve/era/distinto/elpepueconeg/
106
+ 20111009elpneglse_4/Tes">http://www.elpais.com/articulo/primer/plano/
107
+ Steve/era/distinto/elpepueconeg/20111009elpneglse_4/Tes</a></span></p>
108
+ <p><span style="font-size: medium;">Ya se ha publicado la biografía de
109
+ Steve Jobs escrita por Walter Isaacson "<strong>Steve Jobs by Walter
110
+ Isaacson</strong>", aquí os dejamos la dirección de amazon donde
111
+ podeís adquirirla.</span></p>
112
+ <p><span style="font-size: medium;"><a>http://www.amazon.com/Steve-
113
+ Jobs-Walter-Isaacson/dp/1451648537</a></span></p> ' ;
114
+ $ result = $ this ->Text ->truncate ($ text , 500 , array (
115
+ 'ending ' => '... ' ,
116
+ 'exact ' => false ,
117
+ 'html ' => true
118
+ ));
119
+ $ expected = '<p><span style="font-size: medium;">El biógrafo de Steve Jobs, Walter
120
+ Isaacson, explica porqué Jobs le pidió que le hiciera su biografía en
121
+ este artículo de El País.</span></p>
122
+ <p><span style="font-size: medium;"><span style="font-size:
123
+ large;">Por qué Steve era distinto.</span></span></p>
124
+ <p><span style="font-size: medium;"><a href="http://www.elpais.com/
125
+ articulo/primer/plano/Steve/era/distinto/elpepueconeg/
126
+ 20111009elpneglse_4/Tes">http://www.elpais.com/articulo/primer/plano/
127
+ Steve/era/distinto/elpepueconeg/20111009elpneglse_4/Tes</a></span></p>
128
+ <p><span style="font-size: medium;">Ya se ha publicado la biografía de
129
+ Steve Jobs escrita por Walter Isaacson "<strong>Steve Jobs by Walter
130
+ Isaacson</strong>", aquí os dejamos la dirección de amazon donde
131
+ podeís adquirirla.</span></p>
132
+ <p><span style="font-size: medium;"><a>... </p></span></a> ' ;
133
+ $ this ->assertEquals ($ expected , $ result );
89
134
}
90
135
91
136
/**
0 commit comments