Browse Source

Add a test for edge case. Remove an unneeded test.

In the current master branch, the following code will break the HTML
structure in the text, and will display `1...</b>` unexpectedly:
```
Text::truncate('1 <b>2 345</b>', 6, [
    'exact' => false,
    'html' => true,
    'ellipsis' => '...'
])
```
Now it works fine.
chinpei215 9 years ago
parent
commit
19720e5151
1 changed files with 1 additions and 3 deletions
  1. 1 3
      tests/TestCase/Utility/TextTest.php

+ 1 - 3
tests/TestCase/Utility/TextTest.php

@@ -569,6 +569,7 @@ TEXT;
         $this->assertSame('Vive la R' . chr(195) . chr(169) . 'pu...', $this->Text->truncate($text8, 15));
         $this->assertSame('НОПРСТУ...', $this->Text->truncate($text9, 10));
         $this->assertSame('http://example.com/somethin...', $this->Text->truncate($text10, 30));
+        $this->assertSame('1 <b>2...</b>', $this->Text->truncate('1 <b>2 345</b>', 6, ['exact' => false, 'html' => true, 'ellipsis' => '...']));
 
         $text = '<p><span style="font-size: medium;"><a>Iamatestwithnospacesandhtml</a></span></p>';
         $result = $this->Text->truncate($text, 10, [
@@ -1821,9 +1822,6 @@ HTML;
             return $method->invokeArgs(null, func_get_args());
         };
 
-        $text = '&#x3042;&#x3044;&#x3046;&#x3048;&#x3048;';
-        $this->assertEquals('&#x3044;&#x3046;&#x3048;', $substr($text, 1, -1, ['html' => true, 'trimWidth' => true]));
-
         $text = 'データベースアクセス &amp; ORM';
         $this->assertEquals('アクセス', $substr($text, 6, 4, []));
         $this->assertEquals('アクセス', $substr($text, 6, 8, ['trimWidth' => true]));